Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: NASM - The Netwide Assembler (v0.98) |
| 3 | " Maintainer: Manuel M.H. Stol <mmh.stol@gmx.net> |
| 4 | " Last Change: 2003 May 11 |
| 5 | " Vim URL: http://www.vim.org/lang.html |
| 6 | " NASM Home: http://www.cryogen.com/Nasm/ |
| 7 | |
| 8 | |
| 9 | |
| 10 | " Setup Syntax: |
| 11 | " Clear old syntax settings |
| 12 | if version < 600 |
| 13 | syn clear |
| 14 | elseif exists("b:current_syntax") |
| 15 | finish |
| 16 | endif |
| 17 | " Assembler syntax is case insensetive |
| 18 | syn case ignore |
| 19 | |
| 20 | |
| 21 | |
| 22 | " Vim search and movement commands on identifers |
| 23 | if version < 600 |
| 24 | " Comments at start of a line inside which to skip search for indentifiers |
| 25 | set comments=:; |
| 26 | " Identifier Keyword characters (defines \k) |
| 27 | set iskeyword=@,48-57,#,$,.,?,@-@,_,~ |
| 28 | else |
| 29 | " Comments at start of a line inside which to skip search for indentifiers |
| 30 | setlocal comments=:; |
| 31 | " Identifier Keyword characters (defines \k) |
| 32 | setlocal iskeyword=@,48-57,#,$,.,?,@-@,_,~ |
| 33 | endif |
| 34 | |
| 35 | |
| 36 | |
| 37 | " Comments: |
| 38 | syn region nasmComment start=";" keepend end="$" contains=@nasmGrpInComments |
| 39 | syn region nasmSpecialComment start=";\*\*\*" keepend end="$" |
| 40 | syn keyword nasmInCommentTodo contained TODO FIXME XXX[XXXXX] |
| 41 | syn cluster nasmGrpInComments contains=nasmInCommentTodo |
| 42 | syn cluster nasmGrpComments contains=@nasmGrpInComments,nasmComment,nasmSpecialComment |
| 43 | |
| 44 | |
| 45 | |
| 46 | " Label Identifiers: |
| 47 | " in NASM: 'Everything is a Label' |
| 48 | " Definition Label = label defined by %[i]define or %[i]assign |
| 49 | " Identifier Label = label defined as first non-keyword on a line or %[i]macro |
| 50 | syn match nasmLabelError "$\=\(\d\+\K\|[#\.@]\|\$\$\k\)\k*\>" |
| 51 | syn match nasmLabel "\<\(\h\|[?@]\)\k*\>" |
| 52 | syn match nasmLabel "[\$\~]\(\h\|[?@]\)\k*\>"lc=1 |
| 53 | " Labels starting with one or two '.' are special |
| 54 | syn match nasmLocalLabel "\<\.\(\w\|[#$?@~]\)\k*\>" |
| 55 | syn match nasmLocalLabel "\<\$\.\(\w\|[#$?@~]\)\k*\>"ms=s+1 |
| 56 | if !exists("nasm_no_warn") |
| 57 | syn match nasmLabelWarn "\<\~\=\$\=[_\.][_\.\~]*\>" |
| 58 | endif |
| 59 | if exists("nasm_loose_syntax") |
| 60 | syn match nasmSpecialLabel "\<\.\.@\k\+\>" |
| 61 | syn match nasmSpecialLabel "\<\$\.\.@\k\+\>"ms=s+1 |
| 62 | if !exists("nasm_no_warn") |
| 63 | syn match nasmLabelWarn "\<\$\=\.\.@\(\d\|[#$\.~]\)\k*\>" |
| 64 | endif |
| 65 | " disallow use of nasm internal label format |
| 66 | syn match nasmLabelError "\<\$\=\.\.@\d\+\.\k*\>" |
| 67 | else |
| 68 | syn match nasmSpecialLabel "\<\.\.@\(\h\|[?@]\)\k*\>" |
| 69 | syn match nasmSpecialLabel "\<\$\.\.@\(\h\|[?@]\)\k*\>"ms=s+1 |
| 70 | endif |
| 71 | " Labels can be dereferenced with '$' to destinguish them from reserved words |
| 72 | syn match nasmLabelError "\<\$\K\k*\s*:" |
| 73 | syn match nasmLabelError "^\s*\$\K\k*\>" |
| 74 | syn match nasmLabelError "\<\~\s*\(\k*\s*:\|\$\=\.\k*\)" |
| 75 | |
| 76 | |
| 77 | |
| 78 | " Constants: |
| 79 | syn match nasmStringError +["']+ |
| 80 | syn match nasmString +\("[^"]\{-}"\|'[^']\{-}'\)+ |
| 81 | syn match nasmBinNumber "\<[0-1]\+b\>" |
| 82 | syn match nasmBinNumber "\<\~[0-1]\+b\>"lc=1 |
| 83 | syn match nasmOctNumber "\<\o\+q\>" |
| 84 | syn match nasmOctNumber "\<\~\o\+q\>"lc=1 |
| 85 | syn match nasmDecNumber "\<\d\+\>" |
| 86 | syn match nasmDecNumber "\<\~\d\+\>"lc=1 |
| 87 | syn match nasmHexNumber "\<\(\d\x*h\|0x\x\+\|\$\d\x*\)\>" |
| 88 | syn match nasmHexNumber "\<\~\(\d\x*h\|0x\x\+\|\$\d\x*\)\>"lc=1 |
| 89 | syn match nasmFltNumber "\<\d\+\.\d*\(e[+-]\=\d\+\)\=\>" |
| 90 | syn keyword nasmFltNumber Inf Infinity Indefinite NaN SNaN QNaN |
| 91 | syn match nasmNumberError "\<\~\s*\d\+\.\d*\(e[+-]\=\d\+\)\=\>" |
| 92 | |
| 93 | |
| 94 | |
| 95 | " Netwide Assembler Storage Directives: |
| 96 | " Storage types |
| 97 | syn keyword nasmTypeError DF EXTRN FWORD RESF TBYTE |
| 98 | syn keyword nasmType FAR NEAR SHORT |
| 99 | syn keyword nasmType BYTE WORD DWORD QWORD DQWORD HWORD DHWORD TWORD |
| 100 | syn keyword nasmType CDECL FASTCALL NONE PASCAL STDCALL |
| 101 | syn keyword nasmStorage DB DW DD DQ DDQ DT |
| 102 | syn keyword nasmStorage RESB RESW RESD RESQ RESDQ REST |
| 103 | syn keyword nasmStorage EXTERN GLOBAL COMMON |
| 104 | " Structured storage types |
| 105 | syn match nasmTypeError "\<\(AT\|I\=\(END\)\=\(STRUCT\=\|UNION\)\|I\=END\)\>" |
| 106 | syn match nasmStructureLabel contained "\<\(AT\|I\=\(END\)\=\(STRUCT\=\|UNION\)\|I\=END\)\>" |
| 107 | " structures cannot be nested (yet) -> use: 'keepend' and 're=' |
| 108 | syn cluster nasmGrpCntnStruc contains=ALLBUT,@nasmGrpInComments,nasmMacroDef,@nasmGrpInMacros,@nasmGrpInPreCondits,nasmStructureDef,@nasmGrpInStrucs |
| 109 | syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="^\s*STRUCT\>"hs=e-5 end="^\s*ENDSTRUCT\>"re=e-9 contains=@nasmGrpCntnStruc |
| 110 | syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="^\s*STRUC\>"hs=e-4 end="^\s*ENDSTRUC\>"re=e-8 contains=@nasmGrpCntnStruc |
| 111 | syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="\<ISTRUCT\=\>" end="\<IEND\(STRUCT\=\)\=\>" contains=@nasmGrpCntnStruc,nasmInStructure |
| 112 | " union types are not part of nasm (yet) |
| 113 | "syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="^\s*UNION\>"hs=e-4 end="^\s*ENDUNION\>"re=e-8 contains=@nasmGrpCntnStruc |
| 114 | "syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="\<IUNION\>" end="\<IEND\(UNION\)\=\>" contains=@nasmGrpCntnStruc,nasmInStructure |
| 115 | syn match nasmInStructure contained "^\s*AT\>"hs=e-1 |
| 116 | syn cluster nasmGrpInStrucs contains=nasmStructure,nasmInStructure,nasmStructureLabel |
| 117 | |
| 118 | |
| 119 | |
| 120 | " PreProcessor Instructions: |
| 121 | " NAsm PreProcs start with %, but % is not a character |
| 122 | syn match nasmPreProcError "%{\=\(%\=\k\+\|%%\+\k*\|[+-]\=\d\+\)}\=" |
| 123 | if exists("nasm_loose_syntax") |
| 124 | syn cluster nasmGrpNxtCtx contains=nasmStructureLabel,nasmLabel,nasmLocalLabel,nasmSpecialLabel,nasmLabelError,nasmPreProcError |
| 125 | else |
| 126 | syn cluster nasmGrpNxtCtx contains=nasmStructureLabel,nasmLabel,nasmLabelError,nasmPreProcError |
| 127 | endif |
| 128 | |
| 129 | " Multi-line macro |
| 130 | syn cluster nasmGrpCntnMacro contains=ALLBUT,@nasmGrpInComments,nasmStructureDef,@nasmGrpInStrucs,nasmMacroDef,@nasmGrpPreCondits,nasmMemReference,nasmInMacPreCondit,nasmInMacStrucDef |
| 131 | syn region nasmMacroDef matchgroup=nasmMacro keepend start="^\s*%macro\>"hs=e-5 start="^\s*%imacro\>"hs=e-6 end="^\s*%endmacro\>"re=e-9 contains=@nasmGrpCntnMacro,nasmInMacStrucDef |
| 132 | if exists("nasm_loose_syntax") |
| 133 | syn match nasmInMacLabel contained "%\(%\k\+\>\|{%\k\+}\)" |
| 134 | syn match nasmInMacLabel contained "%\($\+\(\w\|[#\.?@~]\)\k*\>\|{$\+\(\w\|[#\.?@~]\)\k*}\)" |
| 135 | syn match nasmInMacPreProc contained "^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=nasmStructureLabel,nasmLabel,nasmInMacParam,nasmLocalLabel,nasmSpecialLabel,nasmLabelError,nasmPreProcError |
| 136 | if !exists("nasm_no_warn") |
| 137 | syn match nasmInMacLblWarn contained "%\(%[$\.]\k*\>\|{%[$\.]\k*}\)" |
| 138 | syn match nasmInMacLblWarn contained "%\($\+\(\d\|[#\.@~]\)\k*\|{\$\+\(\d\|[#\.@~]\)\k*}\)" |
| 139 | hi link nasmInMacCatLabel nasmInMacLblWarn |
| 140 | else |
| 141 | hi link nasmInMacCatLabel nasmInMacLabel |
| 142 | endif |
| 143 | else |
| 144 | syn match nasmInMacLabel contained "%\(%\(\w\|[#?@~]\)\k*\>\|{%\(\w\|[#?@~]\)\k*}\)" |
| 145 | syn match nasmInMacLabel contained "%\($\+\(\h\|[?@]\)\k*\>\|{$\+\(\h\|[?@]\)\k*}\)" |
| 146 | hi link nasmInMacCatLabel nasmLabelError |
| 147 | endif |
| 148 | syn match nasmInMacCatLabel contained "\d\K\k*"lc=1 |
| 149 | syn match nasmInMacLabel contained "\d}\k\+"lc=2 |
| 150 | if !exists("nasm_no_warn") |
| 151 | syn match nasmInMacLblWarn contained "%\(\($\+\|%\)[_~][._~]*\>\|{\($\+\|%\)[_~][._~]*}\)" |
| 152 | endif |
| 153 | syn match nasmInMacPreProc contained "^\s*%pop\>"hs=e-3 |
| 154 | syn match nasmInMacPreProc contained "^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=@nasmGrpNxtCtx |
| 155 | " structures cannot be nested (yet) -> use: 'keepend' and 're=' |
| 156 | syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="^\s*STRUCT\>"hs=e-5 end="^\s*ENDSTRUCT\>"re=e-9 contains=@nasmGrpCntnMacro |
| 157 | syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="^\s*STRUC\>"hs=e-4 end="^\s*ENDSTRUC\>"re=e-8 contains=@nasmGrpCntnMacro |
| 158 | syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="\<ISTRUCT\=\>" end="\<IEND\(STRUCT\=\)\=\>" contains=@nasmGrpCntnMacro,nasmInStructure |
| 159 | " union types are not part of nasm (yet) |
| 160 | "syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="^\s*UNION\>"hs=e-4 end="^\s*ENDUNION\>"re=e-8 contains=@nasmGrpCntnMacro |
| 161 | "syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="\<IUNION\>" end="\<IEND\(UNION\)\=\>" contains=@nasmGrpCntnMacro,nasmInStructure |
| 162 | syn region nasmInMacPreConDef contained transparent matchgroup=nasmInMacPreCondit start="^\s*%ifnidni\>"hs=e-7 start="^\s*%if\(idni\|n\(ctx\|def\|idn\|num\|str\)\)\>"hs=e-6 start="^\s*%if\(ctx\|def\|idn\|nid\|num\|str\)\>"hs=e-5 start="^\s*%ifid\>"hs=e-4 start="^\s*%if\>"hs=e-2 end="%endif\>" contains=@nasmGrpCntnMacro,nasmInMacPreCondit,nasmInPreCondit |
| 163 | syn match nasmInMacPreCondit contained transparent "ctx\s"lc=3 skipwhite nextgroup=@nasmGrpNxtCtx |
| 164 | syn match nasmInMacPreCondit contained "^\s*%elifctx\>"hs=e-7 skipwhite nextgroup=@nasmGrpNxtCtx |
| 165 | syn match nasmInMacPreCondit contained "^\s*%elifnctx\>"hs=e-8 skipwhite nextgroup=@nasmGrpNxtCtx |
| 166 | syn match nasmInMacParamNum contained "\<\d\+\.list\>"me=e-5 |
| 167 | syn match nasmInMacParamNum contained "\<\d\+\.nolist\>"me=e-7 |
| 168 | syn match nasmInMacDirective contained "\.\(no\)\=list\>" |
| 169 | syn match nasmInMacMacro contained transparent "macro\s"lc=5 skipwhite nextgroup=nasmStructureLabel |
| 170 | syn match nasmInMacMacro contained "^\s*%rotate\>"hs=e-6 |
| 171 | syn match nasmInMacParam contained "%\([+-]\=\d\+\|{[+-]\=\d\+}\)" |
| 172 | " nasm conditional macro operands/arguments |
| 173 | " Todo: check feasebility; add too nasmGrpInMacros, etc. |
| 174 | "syn match nasmInMacCond contained "\<\(N\=\([ABGL]E\=\|[CEOSZ]\)\|P[EO]\=\)\>" |
| 175 | syn cluster nasmGrpInMacros contains=nasmMacro,nasmInMacMacro,nasmInMacParam,nasmInMacParamNum,nasmInMacDirective,nasmInMacLabel,nasmInMacLblWarn,nasmInMacMemRef,nasmInMacPreConDef,nasmInMacPreCondit,nasmInMacPreProc,nasmInMacStrucDef |
| 176 | |
| 177 | " Context pre-procs that are better used inside a macro |
| 178 | if exists("nasm_ctx_outside_macro") |
| 179 | syn region nasmPreConditDef transparent matchgroup=nasmCtxPreCondit start="^\s*%ifnctx\>"hs=e-6 start="^\s*%ifctx\>"hs=e-5 end="%endif\>" contains=@nasmGrpCntnPreCon |
| 180 | syn match nasmCtxPreProc "^\s*%pop\>"hs=e-3 |
| 181 | if exists("nasm_loose_syntax") |
| 182 | syn match nasmCtxLocLabel "%$\+\(\w\|[#\.?@~]\)\k*\>" |
| 183 | else |
| 184 | syn match nasmCtxLocLabel "%$\+\(\h\|[?@]\)\k*\>" |
| 185 | endif |
| 186 | syn match nasmCtxPreProc "^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=@nasmGrpNxtCtx |
| 187 | syn match nasmCtxPreCondit contained transparent "ctx\s"lc=3 skipwhite nextgroup=@nasmGrpNxtCtx |
| 188 | syn match nasmCtxPreCondit contained "^\s*%elifctx\>"hs=e-7 skipwhite nextgroup=@nasmGrpNxtCtx |
| 189 | syn match nasmCtxPreCondit contained "^\s*%elifnctx\>"hs=e-8 skipwhite nextgroup=@nasmGrpNxtCtx |
| 190 | if exists("nasm_no_warn") |
| 191 | hi link nasmCtxPreCondit nasmPreCondit |
| 192 | hi link nasmCtxPreProc nasmPreProc |
| 193 | hi link nasmCtxLocLabel nasmLocalLabel |
| 194 | else |
| 195 | hi link nasmCtxPreCondit nasmPreProcWarn |
| 196 | hi link nasmCtxPreProc nasmPreProcWarn |
| 197 | hi link nasmCtxLocLabel nasmLabelWarn |
| 198 | endif |
| 199 | endif |
| 200 | |
| 201 | " Conditional assembly |
| 202 | syn cluster nasmGrpCntnPreCon contains=ALLBUT,@nasmGrpInComments,@nasmGrpInMacros,@nasmGrpInStrucs |
| 203 | syn region nasmPreConditDef transparent matchgroup=nasmPreCondit start="^\s*%ifnidni\>"hs=e-7 start="^\s*%if\(idni\|n\(def\|idn\|num\|str\)\)\>"hs=e-6 start="^\s*%if\(def\|idn\|nid\|num\|str\)\>"hs=e-5 start="^\s*%ifid\>"hs=e-4 start="^\s*%if\>"hs=e-2 end="%endif\>" contains=@nasmGrpCntnPreCon |
| 204 | syn match nasmInPreCondit contained "^\s*%el\(if\|se\)\>"hs=e-4 |
| 205 | syn match nasmInPreCondit contained "^\s*%elifid\>"hs=e-6 |
| 206 | syn match nasmInPreCondit contained "^\s*%elif\(def\|idn\|nid\|num\|str\)\>"hs=e-7 |
| 207 | syn match nasmInPreCondit contained "^\s*%elif\(n\(def\|idn\|num\|str\)\|idni\)\>"hs=e-8 |
| 208 | syn match nasmInPreCondit contained "^\s*%elifnidni\>"hs=e-9 |
| 209 | syn cluster nasmGrpInPreCondits contains=nasmPreCondit,nasmInPreCondit,nasmCtxPreCondit |
| 210 | syn cluster nasmGrpPreCondits contains=nasmPreConditDef,@nasmGrpInPreCondits,nasmCtxPreProc,nasmCtxLocLabel |
| 211 | |
| 212 | " Other pre-processor statements |
| 213 | syn match nasmPreProc "^\s*%rep\>"hs=e-3 |
| 214 | syn match nasmPreProc "^\s*%line\>"hs=e-4 |
| 215 | syn match nasmPreProc "^\s*%\(clear\|error\)\>"hs=e-5 |
| 216 | syn match nasmPreProc "^\s*%endrep\>"hs=e-6 |
| 217 | syn match nasmPreProc "^\s*%exitrep\>"hs=e-7 |
| 218 | syn match nasmDefine "^\s*%undef\>"hs=e-5 |
| 219 | syn match nasmDefine "^\s*%\(assign\|define\)\>"hs=e-6 |
| 220 | syn match nasmDefine "^\s*%i\(assign\|define\)\>"hs=e-7 |
| 221 | syn match nasmInclude "^\s*%include\>"hs=e-7 |
| 222 | |
| 223 | " Multiple pre-processor instructions on single line detection (obsolete) |
| 224 | "syn match nasmPreProcError +^\s*\([^\t "%';][^"%';]*\|[^\t "';][^"%';]\+\)%\a\+\>+ |
| 225 | syn cluster nasmGrpPreProcs contains=nasmMacroDef,@nasmGrpInMacros,@nasmGrpPreCondits,nasmPreProc,nasmDefine,nasmInclude,nasmPreProcWarn,nasmPreProcError |
| 226 | |
| 227 | |
| 228 | |
| 229 | " Register Identifiers: |
| 230 | " Register operands: |
| 231 | syn match nasmGen08Register "\<[A-D][HL]\>" |
| 232 | syn match nasmGen16Register "\<\([A-D]X\|[DS]I\|[BS]P\)\>" |
| 233 | syn match nasmGen32Register "\<E\([A-D]X\|[DS]I\|[BS]P\)\>" |
| 234 | syn match nasmSegRegister "\<[C-GS]S\>" |
| 235 | syn match nasmSpcRegister "\<E\=IP\>" |
| 236 | syn match nasmFpuRegister "\<ST\o\>" |
| 237 | syn match nasmMmxRegister "\<MM\o\>" |
| 238 | syn match nasmSseRegister "\<XMM\o\>" |
| 239 | syn match nasmCtrlRegister "\<CR\o\>" |
| 240 | syn match nasmDebugRegister "\<DR\o\>" |
| 241 | syn match nasmTestRegister "\<TR\o\>" |
| 242 | syn match nasmRegisterError "\<\(CR[15-9]\|DR[4-58-9]\|TR[0-28-9]\)\>" |
| 243 | syn match nasmRegisterError "\<X\=MM[8-9]\>" |
| 244 | syn match nasmRegisterError "\<ST\((\d)\|[8-9]\>\)" |
| 245 | syn match nasmRegisterError "\<E\([A-D][HL]\|[C-GS]S\)\>" |
| 246 | " Memory reference operand (address): |
| 247 | syn match nasmMemRefError "[\[\]]" |
| 248 | syn cluster nasmGrpCntnMemRef contains=ALLBUT,@nasmGrpComments,@nasmGrpPreProcs,@nasmGrpInStrucs,nasmMemReference,nasmMemRefError |
| 249 | syn match nasmInMacMemRef contained "\[[^;\[\]]\{-}\]" contains=@nasmGrpCntnMemRef,nasmPreProcError,nasmInMacLabel,nasmInMacLblWarn,nasmInMacParam |
| 250 | syn match nasmMemReference "\[[^;\[\]]\{-}\]" contains=@nasmGrpCntnMemRef,nasmPreProcError,nasmCtxLocLabel |
| 251 | |
| 252 | |
| 253 | |
| 254 | " Netwide Assembler Directives: |
| 255 | " Compilation constants |
| 256 | syn keyword nasmConstant __BITS__ __DATE__ __FILE__ __FORMAT__ __LINE__ |
| 257 | syn keyword nasmConstant __NASM_MAJOR__ __NASM_MINOR__ __NASM_VERSION__ |
| 258 | syn keyword nasmConstant __TIME__ |
| 259 | " Instruction modifiers |
| 260 | syn match nasmInstructnError "\<TO\>" |
| 261 | syn match nasmInstrModifier "\(^\|:\)\s*[C-GS]S\>"ms=e-1 |
| 262 | syn keyword nasmInstrModifier A16 A32 O16 O32 |
| 263 | syn match nasmInstrModifier "\<F\(ADD\|MUL\|\(DIV\|SUB\)R\=\)\s\+TO\>"lc=5,ms=e-1 |
| 264 | " the 'to' keyword is not allowed for fpu-pop instructions (yet) |
| 265 | "syn match nasmInstrModifier "\<F\(ADD\|MUL\|\(DIV\|SUB\)R\=\)P\s\+TO\>"lc=6,ms=e-1 |
| 266 | " NAsm directives |
| 267 | syn keyword nasmRepeat TIMES |
| 268 | syn keyword nasmDirective ALIGN[B] INCBIN EQU NOSPLIT SPLIT |
| 269 | syn keyword nasmDirective ABSOLUTE BITS SECTION SEGMENT |
| 270 | syn keyword nasmDirective ENDSECTION ENDSEGMENT |
| 271 | syn keyword nasmDirective __SECT__ |
| 272 | " Macro created standard directives: (requires %include) |
| 273 | syn case match |
| 274 | syn keyword nasmStdDirective ENDPROC EPILOGUE LOCALS PROC PROLOGUE USES |
| 275 | syn keyword nasmStdDirective ENDIF ELSE ELIF ELSIF IF |
| 276 | "syn keyword nasmStdDirective BREAK CASE DEFAULT ENDSWITCH SWITCH |
| 277 | "syn keyword nasmStdDirective CASE OF ENDCASE |
| 278 | syn keyword nasmStdDirective DO ENDFOR ENDWHILE FOR REPEAT UNTIL WHILE EXIT |
| 279 | syn case ignore |
| 280 | " Format specific directives: (all formats) |
| 281 | " (excluded: extension directives to section, global, common and extern) |
| 282 | syn keyword nasmFmtDirective ORG |
| 283 | syn keyword nasmFmtDirective EXPORT IMPORT GROUP UPPERCASE SEG WRT |
| 284 | syn keyword nasmFmtDirective LIBRARY |
| 285 | syn case match |
| 286 | syn keyword nasmFmtDirective _GLOBAL_OFFSET_TABLE_ __GLOBAL_OFFSET_TABLE_ |
| 287 | syn keyword nasmFmtDirective ..start ..got ..gotoff ..gotpc ..plt ..sym |
| 288 | syn case ignore |
| 289 | |
| 290 | |
| 291 | |
| 292 | " Standard Instructions: |
| 293 | syn match nasmInstructnError "\<\(F\=CMOV\|SET\)N\=\a\{0,2}\>" |
| 294 | syn keyword nasmInstructnError CMPS MOVS LCS LODS STOS XLAT |
| 295 | syn match nasmStdInstruction "\<MOV\>" |
| 296 | syn match nasmInstructnError "\<MOV\s[^,;[]*\<CS\>\s*[^:]"he=e-1 |
| 297 | syn match nasmStdInstruction "\<\(CMOV\|J\|SET\)\(N\=\([ABGL]E\=\|[CEOSZ]\)\|P[EO]\=\)\>" |
| 298 | syn match nasmStdInstruction "\<POP\>" |
| 299 | syn keyword nasmStdInstruction AAA AAD AAM AAS ADC ADD AND |
| 300 | syn keyword nasmStdInstruction BOUND BSF BSR BSWAP BT[C] BTR BTS |
| 301 | syn keyword nasmStdInstruction CALL CBW CDQ CLC CLD CMC CMP CMPSB CMPSD CMPSW |
| 302 | syn keyword nasmStdInstruction CMPXCHG CMPXCHG8B CPUID CWD[E] |
| 303 | syn keyword nasmStdInstruction DAA DAS DEC DIV ENTER |
| 304 | syn keyword nasmStdInstruction IDIV IMUL INC INT[O] IRET[D] IRETW |
| 305 | syn keyword nasmStdInstruction JCXZ JECXZ JMP |
| 306 | syn keyword nasmStdInstruction LAHF LDS LEA LEAVE LES LFS LGS LODSB LODSD |
| 307 | syn keyword nasmStdInstruction LODSW LOOP[E] LOOPNE LOOPNZ LOOPZ LSS |
| 308 | syn keyword nasmStdInstruction MOVSB MOVSD MOVSW MOVSX MOVZX MUL NEG NOP NOT |
| 309 | syn keyword nasmStdInstruction OR POPA[D] POPAW POPF[D] POPFW |
| 310 | syn keyword nasmStdInstruction PUSH[AD] PUSHAW PUSHF[D] PUSHFW |
| 311 | syn keyword nasmStdInstruction RCL RCR RETF RET[N] ROL ROR |
| 312 | syn keyword nasmStdInstruction SAHF SAL SAR SBB SCASB SCASD SCASW |
| 313 | syn keyword nasmStdInstruction SHL[D] SHR[D] STC STD STOSB STOSD STOSW SUB |
| 314 | syn keyword nasmStdInstruction TEST XADD XCHG XLATB XOR |
| 315 | |
| 316 | |
| 317 | " System Instructions: (usually privileged) |
| 318 | " Verification of pointer parameters |
| 319 | syn keyword nasmSysInstruction ARPL LAR LSL VERR VERW |
| 320 | " Addressing descriptor tables |
| 321 | syn keyword nasmSysInstruction LLDT SLDT LGDT SGDT |
| 322 | " Multitasking |
| 323 | syn keyword nasmSysInstruction LTR STR |
| 324 | " Coprocessing and Multiprocessing (requires fpu and multiple cpu's resp.) |
| 325 | syn keyword nasmSysInstruction CLTS LOCK WAIT |
| 326 | " Input and Output |
| 327 | syn keyword nasmInstructnError INS OUTS |
| 328 | syn keyword nasmSysInstruction IN INSB INSW INSD OUT OUTSB OUTSB OUTSW OUTSD |
| 329 | " Interrupt control |
| 330 | syn keyword nasmSysInstruction CLI STI LIDT SIDT |
| 331 | " System control |
| 332 | syn match nasmSysInstruction "\<MOV\s[^;]\{-}\<CR\o\>"me=s+3 |
| 333 | syn keyword nasmSysInstruction HLT INVD LMSW |
| 334 | syn keyword nasmSseInstruction PREFETCHT0 PREFETCHT1 PREFETCHT2 PREFETCHNTA |
| 335 | syn keyword nasmSseInstruction RSM SFENCE SMSW SYSENTER SYSEXIT UD2 WBINVD |
| 336 | " TLB (Translation Lookahead Buffer) testing |
| 337 | syn match nasmSysInstruction "\<MOV\s[^;]\{-}\<TR\o\>"me=s+3 |
| 338 | syn keyword nasmSysInstruction INVLPG |
| 339 | |
| 340 | " Debugging Instructions: (privileged) |
| 341 | syn match nasmDbgInstruction "\<MOV\s[^;]\{-}\<DR\o\>"me=s+3 |
| 342 | syn keyword nasmDbgInstruction INT1 INT3 RDMSR RDTSC RDPMC WRMSR |
| 343 | |
| 344 | |
| 345 | " Floating Point Instructions: (requires FPU) |
| 346 | syn match nasmFpuInstruction "\<FCMOVN\=\([AB]E\=\|[CEPUZ]\)\>" |
| 347 | syn keyword nasmFpuInstruction F2XM1 FABS FADD[P] FBLD FBSTP |
| 348 | syn keyword nasmFpuInstruction FCHS FCLEX FCOM[IP] FCOMP[P] FCOS |
| 349 | syn keyword nasmFpuInstruction FDECSTP FDISI FDIV[P] FDIVR[P] FENI FFREE |
| 350 | syn keyword nasmFpuInstruction FIADD FICOM[P] FIDIV[R] FILD |
| 351 | syn keyword nasmFpuInstruction FIMUL FINCSTP FINIT FIST[P] FISUB[R] |
| 352 | syn keyword nasmFpuInstruction FLD[1] FLDCW FLDENV FLDL2E FLDL2T FLDLG2 |
| 353 | syn keyword nasmFpuInstruction FLDLN2 FLDPI FLDZ FMUL[P] |
| 354 | syn keyword nasmFpuInstruction FNCLEX FNDISI FNENI FNINIT FNOP FNSAVE |
| 355 | syn keyword nasmFpuInstruction FNSTCW FNSTENV FNSTSW FNSTSW |
| 356 | syn keyword nasmFpuInstruction FPATAN FPREM[1] FPTAN FRNDINT FRSTOR |
| 357 | syn keyword nasmFpuInstruction FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT |
| 358 | syn keyword nasmFpuInstruction FSTCW FSTENV FST[P] FSTSW FSUB[P] FSUBR[P] |
| 359 | syn keyword nasmFpuInstruction FTST FUCOM[IP] FUCOMP[P] |
| 360 | syn keyword nasmFpuInstruction FXAM FXCH FXTRACT FYL2X FYL2XP1 |
| 361 | |
| 362 | |
| 363 | " Multi Media Xtension Packed Instructions: (requires MMX unit) |
| 364 | " Standard MMX instructions: (requires MMX1 unit) |
| 365 | syn match nasmInstructnError "\<P\(ADD\|SUB\)U\=S\=[DQ]\=\>" |
| 366 | syn match nasmInstructnError "\<PCMP\a\{0,2}[BDWQ]\=\>" |
| 367 | syn keyword nasmMmxInstruction EMMS MOVD MOVQ |
| 368 | syn keyword nasmMmxInstruction PACKSSDW PACKSSWB PACKUSWB PADDB PADDD PADDW |
| 369 | syn keyword nasmMmxInstruction PADDSB PADDSW PADDUSB PADDUSW PAND[N] |
| 370 | syn keyword nasmMmxInstruction PCMPEQB PCMPEQD PCMPEQW PCMPGTB PCMPGTD PCMPGTW |
| 371 | syn keyword nasmMmxInstruction PMACHRIW PMADDWD PMULHW PMULLW POR |
| 372 | syn keyword nasmMmxInstruction PSLLD PSLLQ PSLLW PSRAD PSRAW PSRLD PSRLQ PSRLW |
| 373 | syn keyword nasmMmxInstruction PSUBB PSUBD PSUBW PSUBSB PSUBSW PSUBUSB PSUBUSW |
| 374 | syn keyword nasmMmxInstruction PUNPCKHBW PUNPCKHDQ PUNPCKHWD |
| 375 | syn keyword nasmMmxInstruction PUNPCKLBW PUNPCKLDQ PUNPCKLWD PXOR |
| 376 | " Extended MMX instructions: (requires MMX2/SSE unit) |
| 377 | syn keyword nasmMmxInstruction MASKMOVQ MOVNTQ |
| 378 | syn keyword nasmMmxInstruction PAVGB PAVGW PEXTRW PINSRW PMAXSW PMAXUB |
| 379 | syn keyword nasmMmxInstruction PMINSW PMINUB PMOVMSKB PMULHUW PSADBW PSHUFW |
| 380 | |
| 381 | |
| 382 | " Streaming SIMD Extension Packed Instructions: (requires SSE unit) |
| 383 | syn match nasmInstructnError "\<CMP\a\{1,5}[PS]S\>" |
| 384 | syn match nasmSseInstruction "\<CMP\(N\=\(EQ\|L[ET]\)\|\(UN\)\=ORD\)\=[PS]S\>" |
| 385 | syn keyword nasmSseInstruction ADDPS ADDSS ANDNPS ANDPS |
| 386 | syn keyword nasmSseInstruction COMISS CVTPI2PS CVTPS2PI |
| 387 | syn keyword nasmSseInstruction CVTSI2SS CVTSS2SI CVTTPS2PI CVTTSS2SI |
| 388 | syn keyword nasmSseInstruction DIVPS DIVSS FXRSTOR FXSAVE LDMXCSR |
| 389 | syn keyword nasmSseInstruction MAXPS MAXSS MINPS MINSS MOVAPS MOVHLPS MOVHPS |
| 390 | syn keyword nasmSseInstruction MOVLHPS MOVLPS MOVMSKPS MOVNTPS MOVSS MOVUPS |
| 391 | syn keyword nasmSseInstruction MULPS MULSS |
| 392 | syn keyword nasmSseInstruction ORPS RCPPS RCPSS RSQRTPS RSQRTSS |
| 393 | syn keyword nasmSseInstruction SHUFPS SQRTPS SQRTSS STMXCSR SUBPS SUBSS |
| 394 | syn keyword nasmSseInstruction UCOMISS UNPCKHPS UNPCKLPS XORPS |
| 395 | |
| 396 | |
| 397 | " Three Dimensional Now Packed Instructions: (requires 3DNow! unit) |
| 398 | syn keyword nasmNowInstruction FEMMS PAVGUSB PF2ID PFACC PFADD PFCMPEQ PFCMPGE |
| 399 | syn keyword nasmNowInstruction PFCMPGT PFMAX PFMIN PFMUL PFRCP PFRCPIT1 |
| 400 | syn keyword nasmNowInstruction PFRCPIT2 PFRSQIT1 PFRSQRT PFSUB[R] PI2FD |
| 401 | syn keyword nasmNowInstruction PMULHRWA PREFETCH[W] |
| 402 | |
| 403 | |
| 404 | " Vendor Specific Instructions: |
| 405 | " Cyrix instructions (requires Cyrix processor) |
| 406 | syn keyword nasmCrxInstruction PADDSIW PAVEB PDISTIB PMAGW PMULHRW[C] PMULHRIW |
| 407 | syn keyword nasmCrxInstruction PMVGEZB PMVLZB PMVNZB PMVZB PSUBSIW |
| 408 | syn keyword nasmCrxInstruction RDSHR RSDC RSLDT SMINT SMINTOLD SVDC SVLDT SVTS |
| 409 | syn keyword nasmCrxInstruction WRSHR |
| 410 | " AMD instructions (requires AMD processor) |
| 411 | syn keyword nasmAmdInstruction SYSCALL SYSRET |
| 412 | |
| 413 | |
| 414 | " Undocumented Instructions: |
| 415 | syn match nasmUndInstruction "\<POP\s[^;]*\<CS\>"me=s+3 |
| 416 | syn keyword nasmUndInstruction CMPXCHG486 IBTS ICEBP INT01 INT03 LOADALL |
| 417 | syn keyword nasmUndInstruction LOADALL286 LOADALL386 SALC SMI UD1 UMOV XBTS |
| 418 | |
| 419 | |
| 420 | |
| 421 | " Synchronize Syntax: |
| 422 | syn sync clear |
| 423 | syn sync minlines=50 "for multiple region nesting |
| 424 | syn sync match nasmSync grouphere nasmMacroDef "^\s*%i\=macro\>"me=s-1 |
| 425 | syn sync match nasmSync grouphere NONE "^\s*%endmacro\>" |
| 426 | |
| 427 | |
| 428 | " Define the default highlighting. |
| 429 | " For version 5.7 and earlier: only when not done already |
| 430 | " For version 5.8 and later : only when an item doesn't have highlighting yet |
| 431 | if version >= 508 || !exists("did_nasm_syntax_inits") |
| 432 | if version < 508 |
| 433 | let did_nasm_syntax_inits = 1 |
| 434 | command -nargs=+ HiLink hi link <args> |
| 435 | else |
| 436 | command -nargs=+ HiLink hi def link <args> |
| 437 | endif |
| 438 | |
| 439 | " Sub Links: |
| 440 | HiLink nasmInMacDirective nasmDirective |
| 441 | HiLink nasmInMacLabel nasmLocalLabel |
| 442 | HiLink nasmInMacLblWarn nasmLabelWarn |
| 443 | HiLink nasmInMacMacro nasmMacro |
| 444 | HiLink nasmInMacParam nasmMacro |
| 445 | HiLink nasmInMacParamNum nasmDecNumber |
| 446 | HiLink nasmInMacPreCondit nasmPreCondit |
| 447 | HiLink nasmInMacPreProc nasmPreProc |
| 448 | HiLink nasmInPreCondit nasmPreCondit |
| 449 | HiLink nasmInStructure nasmStructure |
| 450 | HiLink nasmStructureLabel nasmStructure |
| 451 | |
| 452 | " Comment Group: |
| 453 | HiLink nasmComment Comment |
| 454 | HiLink nasmSpecialComment SpecialComment |
| 455 | HiLink nasmInCommentTodo Todo |
| 456 | |
| 457 | " Constant Group: |
| 458 | HiLink nasmString String |
| 459 | HiLink nasmStringError Error |
| 460 | HiLink nasmBinNumber Number |
| 461 | HiLink nasmOctNumber Number |
| 462 | HiLink nasmDecNumber Number |
| 463 | HiLink nasmHexNumber Number |
| 464 | HiLink nasmFltNumber Float |
| 465 | HiLink nasmNumberError Error |
| 466 | |
| 467 | " Identifier Group: |
| 468 | HiLink nasmLabel Identifier |
| 469 | HiLink nasmLocalLabel Identifier |
| 470 | HiLink nasmSpecialLabel Special |
| 471 | HiLink nasmLabelError Error |
| 472 | HiLink nasmLabelWarn Todo |
| 473 | |
| 474 | " PreProc Group: |
| 475 | HiLink nasmPreProc PreProc |
| 476 | HiLink nasmDefine Define |
| 477 | HiLink nasmInclude Include |
| 478 | HiLink nasmMacro Macro |
| 479 | HiLink nasmPreCondit PreCondit |
| 480 | HiLink nasmPreProcError Error |
| 481 | HiLink nasmPreProcWarn Todo |
| 482 | |
| 483 | " Type Group: |
| 484 | HiLink nasmType Type |
| 485 | HiLink nasmStorage StorageClass |
| 486 | HiLink nasmStructure Structure |
| 487 | HiLink nasmTypeError Error |
| 488 | |
| 489 | " Directive Group: |
| 490 | HiLink nasmConstant Constant |
| 491 | HiLink nasmInstrModifier Operator |
| 492 | HiLink nasmRepeat Repeat |
| 493 | HiLink nasmDirective Keyword |
| 494 | HiLink nasmStdDirective Operator |
| 495 | HiLink nasmFmtDirective Keyword |
| 496 | |
| 497 | " Register Group: |
| 498 | HiLink nasmCtrlRegister Special |
| 499 | HiLink nasmDebugRegister Debug |
| 500 | HiLink nasmTestRegister Special |
| 501 | HiLink nasmRegisterError Error |
| 502 | HiLink nasmMemRefError Error |
| 503 | |
| 504 | " Instruction Group: |
| 505 | HiLink nasmStdInstruction Statement |
| 506 | HiLink nasmSysInstruction Statement |
| 507 | HiLink nasmDbgInstruction Debug |
| 508 | HiLink nasmFpuInstruction Statement |
| 509 | HiLink nasmMmxInstruction Statement |
| 510 | HiLink nasmSseInstruction Statement |
| 511 | HiLink nasmNowInstruction Statement |
| 512 | HiLink nasmAmdInstruction Special |
| 513 | HiLink nasmCrxInstruction Special |
| 514 | HiLink nasmUndInstruction Todo |
| 515 | HiLink nasmInstructnError Error |
| 516 | |
| 517 | delcommand HiLink |
| 518 | endif |
| 519 | |
| 520 | let b:current_syntax = "nasm" |
| 521 | |
| 522 | " vim:ts=8 sw=4 |