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