2 " Language: Microsoft Macro Assembler (80x86)
3 " Orig Author: Rob Brady <robb@datatone.com>
4 " Maintainer: Wu Yongwei <wuyongwei@gmail.com>
5 " Last Change: $Date: 2007/04/21 13:20:15 $
8 " For version 5.x: Clear all syntax items
9 " For version 6.x: Quit when a syntax file was already loaded
12 elseif exists("b:current_syntax")
19 syn match masmIdentifier "[@a-z_$?][@a-z0-9_$?]*"
20 syn match masmLabel "^\s*[@a-z_$?][@a-z0-9_$?]*:"he=e-1
22 syn match masmDecimal "[-+]\?\d\+[dt]\?"
23 syn match masmBinary "[-+]\?[0-1]\+[by]" "put this before hex or 0bfh dies!
24 syn match masmOctal "[-+]\?[0-7]\+[oq]"
25 syn match masmHexadecimal "[-+]\?[0-9]\x*h"
26 syn match masmFloatRaw "[-+]\?[0-9]\x*r"
27 syn match masmFloat "[-+]\?\d\+\.\(\d*\(E[-+]\?\d\+\)\?\)\?"
29 syn match masmComment ";.*" contains=@Spell
30 syn region masmComment start=+COMMENT\s*\z(\S\)+ end=+\z1.*+ contains=@Spell
31 syn region masmString start=+'+ end=+'+ oneline contains=@Spell
32 syn region masmString start=+"+ end=+"+ oneline contains=@Spell
34 syn region masmTitleArea start=+\<TITLE\s+lc=5 start=+\<SUBTITLE\s+lc=8 start=+\<SUBTTL\s+lc=6 end=+$+ end=+;+me=e-1 contains=masmTitle
35 syn region masmTextArea start=+\<NAME\s+lc=4 start=+\<INCLUDE\s+lc=7 start=+\<INCLUDELIB\s+lc=10 end=+$+ end=+;+me=e-1 contains=masmText
36 syn match masmTitle "[^\t ;]\([^;]*[^\t ;]\)\?" contained contains=@Spell
37 syn match masmText "[^\t ;]\([^;]*[^\t ;]\)\?" contained
39 syn region masmOptionOpt start=+\<OPTION\s+lc=6 end=+$+ end=+;+me=e-1 contains=masmOption
40 syn region masmContextOpt start=+\<PUSHCONTEXT\s+lc=11 start=+\<POPCONTEXT\s+lc=10 end=+$+ end=+;+me=e-1 contains=masmOption
41 syn region masmModelOpt start=+\.MODEL\s+lc=6 end=+$+ end=+;+me=e-1 contains=masmOption,masmType
42 syn region masmSegmentOpt start=+\<SEGMENT\s+lc=7 end=+$+ end=+;+me=e-1 contains=masmOption,masmString
43 syn region masmProcOpt start=+\<PROC\s+lc=4 end=+$+ end=+;+me=e-1 contains=masmOption,masmType,masmRegister,masmIdentifier
44 syn region masmAssumeOpt start=+\<ASSUME\s+lc=6 end=+$+ end=+;+me=e-1 contains=masmOption,masmOperator,masmType,masmRegister,masmIdentifier
45 syn region masmExpression start=+\.IF\s+lc=3 start=+\.WHILE\s+lc=6 start=+\.UNTIL\s+lc=6 start=+\<IF\s+lc=2 start=+\<IF2\s+lc=3 start=+\<ELSEIF\s+lc=6 start=+\<ELSEIF2\s+lc=7 start=+\<REPEAT\s+lc=6 start=+\<WHILE\s+lc=5 end=+$+ end=+;+me=e-1 contains=masmType,masmOperator,masmRegister,masmIdentifier,masmDecimal,masmBinary,masmHexadecimal,masmFloatRaw,masmString
47 syn keyword masmOption TINY SMALL COMPACT MEDIUM LARGE HUGE contained
48 syn keyword masmOption NEARSTACK FARSTACK contained
49 syn keyword masmOption PUBLIC PRIVATE STACK COMMON MEMORY AT contained
50 syn keyword masmOption BYTE WORD DWORD PARA PAGE contained
51 syn keyword masmOption USE16 USE32 FLAT contained
52 syn keyword masmOption INFO READ WRITE EXECUTE SHARED contained
53 syn keyword masmOption NOPAGE NOCACHE DISCARD contained
54 syn keyword masmOption READONLY USES FRAME contained
55 syn keyword masmOption CASEMAP DOTNAME NODOTNAME EMULATOR contained
56 syn keyword masmOption NOEMULATOR EPILOGUE EXPR16 EXPR32 contained
57 syn keyword masmOption LANGUAGE LJMP NOLJMP M510 NOM510 contained
58 syn keyword masmOption NOKEYWORD NOSIGNEXTEND OFFSET contained
59 syn keyword masmOption OLDMACROS NOOLDMACROS OLDSTRUCTS contained
60 syn keyword masmOption NOOLDSTRUCTS PROC PROLOGUE READONLY contained
61 syn keyword masmOption NOREADONLY SCOPED NOSCOPED SEGMENT contained
62 syn keyword masmOption SETIF2 contained
63 syn keyword masmOption ABS ALL ASSUMES CPU ERROR EXPORT contained
64 syn keyword masmOption FORCEFRAME LISTING LOADDS NONE contained
65 syn keyword masmOption NONUNIQUE NOTHING OS_DOS RADIX REQ contained
66 syn keyword masmType STDCALL SYSCALL C BASIC FORTRAN PASCAL
67 syn keyword masmType PTR NEAR FAR NEAR16 FAR16 NEAR32 FAR32
68 syn keyword masmType REAL4 REAL8 REAL10 BYTE SBYTE TBYTE
69 syn keyword masmType WORD DWORD QWORD FWORD SWORD SDWORD
70 syn keyword masmOperator AND NOT OR SHL SHR XOR MOD DUP
71 syn keyword masmOperator EQ GE GT LE LT NE
72 syn keyword masmOperator LROFFSET SEG LENGTH LENGTHOF SIZE SIZEOF
73 syn keyword masmOperator CODEPTR DATAPTR FAR NEAR SHORT THIS TYPE
74 syn keyword masmOperator HIGH HIGHWORD LOW LOWWORD OPATTR MASK WIDTH
75 syn match masmOperator "OFFSET\(\sFLAT:\)\?"
76 syn match masmOperator ".TYPE\>"
77 syn match masmOperator "CARRY?"
78 syn match masmOperator "OVERFLOW?"
79 syn match masmOperator "PARITY?"
80 syn match masmOperator "SIGN?"
81 syn match masmOperator "ZERO?"
82 syn keyword masmDirective ALIAS ASSUME CATSTR COMM DB DD DF DOSSEG DQ DT
83 syn keyword masmDirective DW ECHO ELSE ELSEIF ELSEIF1 ELSEIF2 ELSEIFB
84 syn keyword masmDirective ELSEIFDEF ELSEIFDIF ELSEIFDIFI ELSEIFE
85 syn keyword masmDirective ELSEIFIDN ELSEIFIDNI ELSEIFNB ELSEIFNDEF END
86 syn keyword masmDirective ENDIF ENDM ENDP ENDS EQU EVEN EXITM EXTERN
87 syn keyword masmDirective EXTERNDEF EXTRN FOR FORC GOTO GROUP IF IF1 IF2
88 syn keyword masmDirective IFB IFDEF IFDIF IFDIFI IFE IFIDN IFIDNI IFNB
89 syn keyword masmDirective IFNDEF INCLUDE INCLUDELIB INSTR INVOKE IRP
90 syn keyword masmDirective IRPC LABEL LOCAL MACRO NAME OPTION ORG PAGE
91 syn keyword masmDirective POPCONTEXT PROC PROTO PUBLIC PURGE PUSHCONTEXT
92 syn keyword masmDirective RECORD REPEAT REPT SEGMENT SIZESTR STRUC
93 syn keyword masmDirective STRUCT SUBSTR SUBTITLE SUBTTL TEXTEQU TITLE
94 syn keyword masmDirective TYPEDEF UNION WHILE
95 syn match masmDirective "\.8086\>"
96 syn match masmDirective "\.8087\>"
97 syn match masmDirective "\.NO87\>"
98 syn match masmDirective "\.186\>"
99 syn match masmDirective "\.286\>"
100 syn match masmDirective "\.286C\>"
101 syn match masmDirective "\.286P\>"
102 syn match masmDirective "\.287\>"
103 syn match masmDirective "\.386\>"
104 syn match masmDirective "\.386C\>"
105 syn match masmDirective "\.386P\>"
106 syn match masmDirective "\.387\>"
107 syn match masmDirective "\.486\>"
108 syn match masmDirective "\.486P\>"
109 syn match masmDirective "\.586\>"
110 syn match masmDirective "\.586P\>"
111 syn match masmDirective "\.686\>"
112 syn match masmDirective "\.686P\>"
113 syn match masmDirective "\.K3D\>"
114 syn match masmDirective "\.MMX\>"
115 syn match masmDirective "\.XMM\>"
116 syn match masmDirective "\.ALPHA\>"
117 syn match masmDirective "\.DOSSEG\>"
118 syn match masmDirective "\.SEQ\>"
119 syn match masmDirective "\.CODE\>"
120 syn match masmDirective "\.CONST\>"
121 syn match masmDirective "\.DATA\>"
122 syn match masmDirective "\.DATA?"
123 syn match masmDirective "\.EXIT\>"
124 syn match masmDirective "\.FARDATA\>"
125 syn match masmDirective "\.FARDATA?"
126 syn match masmDirective "\.MODEL\>"
127 syn match masmDirective "\.STACK\>"
128 syn match masmDirective "\.STARTUP\>"
129 syn match masmDirective "\.IF\>"
130 syn match masmDirective "\.ELSE\>"
131 syn match masmDirective "\.ELSEIF\>"
132 syn match masmDirective "\.ENDIF\>"
133 syn match masmDirective "\.REPEAT\>"
134 syn match masmDirective "\.UNTIL\>"
135 syn match masmDirective "\.UNTILCXZ\>"
136 syn match masmDirective "\.WHILE\>"
137 syn match masmDirective "\.ENDW\>"
138 syn match masmDirective "\.BREAK\>"
139 syn match masmDirective "\.CONTINUE\>"
140 syn match masmDirective "\.ERR\>"
141 syn match masmDirective "\.ERR1\>"
142 syn match masmDirective "\.ERR2\>"
143 syn match masmDirective "\.ERRB\>"
144 syn match masmDirective "\.ERRDEF\>"
145 syn match masmDirective "\.ERRDIF\>"
146 syn match masmDirective "\.ERRDIFI\>"
147 syn match masmDirective "\.ERRE\>"
148 syn match masmDirective "\.ERRIDN\>"
149 syn match masmDirective "\.ERRIDNI\>"
150 syn match masmDirective "\.ERRNB\>"
151 syn match masmDirective "\.ERRNDEF\>"
152 syn match masmDirective "\.ERRNZ\>"
153 syn match masmDirective "\.LALL\>"
154 syn match masmDirective "\.SALL\>"
155 syn match masmDirective "\.XALL\>"
156 syn match masmDirective "\.LFCOND\>"
157 syn match masmDirective "\.SFCOND\>"
158 syn match masmDirective "\.TFCOND\>"
159 syn match masmDirective "\.CREF\>"
160 syn match masmDirective "\.NOCREF\>"
161 syn match masmDirective "\.XCREF\>"
162 syn match masmDirective "\.LIST\>"
163 syn match masmDirective "\.NOLIST\>"
164 syn match masmDirective "\.XLIST\>"
165 syn match masmDirective "\.LISTALL\>"
166 syn match masmDirective "\.LISTIF\>"
167 syn match masmDirective "\.NOLISTIF\>"
168 syn match masmDirective "\.LISTMACRO\>"
169 syn match masmDirective "\.NOLISTMACRO\>"
170 syn match masmDirective "\.LISTMACROALL\>"
171 syn match masmDirective "\.FPO\>"
172 syn match masmDirective "\.RADIX\>"
173 syn match masmDirective "\.SAFESEH\>"
174 syn match masmDirective "%OUT\>"
175 syn match masmDirective "ALIGN\>"
176 syn match masmOption "ALIGN([0-9]\+)"
178 syn keyword masmRegister AX BX CX DX SI DI BP SP
179 syn keyword masmRegister CS DS SS ES FS GS
180 syn keyword masmRegister AH BH CH DH AL BL CL DL
181 syn keyword masmRegister EAX EBX ECX EDX ESI EDI EBP ESP
182 syn keyword masmRegister CR0 CR2 CR3 CR4
183 syn keyword masmRegister DR0 DR1 DR2 DR3 DR6 DR7
184 syn keyword masmRegister TR3 TR4 TR5 TR6 TR7
185 syn match masmRegister "ST([0-7])"
188 " Instruction prefixes
189 syn keyword masmOpcode LOCK REP REPE REPNE REPNZ REPZ
192 syn keyword masmOpcode AAA AAD AAM AAS ADC ADD AND CALL CBW CLC CLD
193 syn keyword masmOpcode CLI CMC CMP CMPS CMPSB CMPSW CWD DAA DAS DEC
194 syn keyword masmOpcode DIV ESC HLT IDIV IMUL IN INC INT INTO IRET
195 syn keyword masmOpcode JCXZ JMP LAHF LDS LEA LES LODS LODSB LODSW
196 syn keyword masmOpcode LOOP LOOPE LOOPEW LOOPNE LOOPNEW LOOPNZ
197 syn keyword masmOpcode LOOPNZW LOOPW LOOPZ LOOPZW MOV MOVS MOVSB
198 syn keyword masmOpcode MOVSW MUL NEG NOP NOT OR OUT POP POPF PUSH
199 syn keyword masmOpcode PUSHF RCL RCR RET RETF RETN ROL ROR SAHF SAL
200 syn keyword masmOpcode SAR SBB SCAS SCASB SCASW SHL SHR STC STD STI
201 syn keyword masmOpcode STOS STOSB STOSW SUB TEST WAIT XCHG XLAT XLATB
202 syn keyword masmOpcode XOR
203 syn match masmOpcode "J\(P[EO]\|\(N\?\([ABGL]E\?\|[CEOPSZ]\)\)\)\>"
206 syn keyword masmOpcode BOUND ENTER INS INSB INSW LEAVE OUTS OUTSB
207 syn keyword masmOpcode OUTSW POPA PUSHA PUSHW
210 syn keyword masmOpcode ARPL LAR LSL SGDT SIDT SLDT SMSW STR VERR VERW
212 " 80286/80386 privileged opcodes
213 syn keyword masmOpcode CLTS LGDT LIDT LLDT LMSW LTR
216 syn keyword masmOpcode BSF BSR BT BTC BTR BTS CDQ CMPSD CWDE INSD
217 syn keyword masmOpcode IRETD IRETDF IRETF JECXZ LFS LGS LODSD LOOPD
218 syn keyword masmOpcode LOOPED LOOPNED LOOPNZD LOOPZD LSS MOVSD MOVSX
219 syn keyword masmOpcode MOVZX OUTSD POPAD POPFD PUSHAD PUSHD PUSHFD
220 syn keyword masmOpcode SCASD SHLD SHRD STOSD
221 syn match masmOpcode "SET\(P[EO]\|\(N\?\([ABGL]E\?\|[CEOPSZ]\)\)\)\>"
224 syn keyword masmOpcode BSWAP CMPXCHG INVD INVLPG WBINVD XADD
226 " Floating-point opcodes as of 487
227 syn keyword masmOpFloat F2XM1 FABS FADD FADDP FBLD FBSTP FCHS FCLEX
228 syn keyword masmOpFloat FNCLEX FCOM FCOMP FCOMPP FCOS FDECSTP FDISI
229 syn keyword masmOpFloat FNDISI FDIV FDIVP FDIVR FDIVRP FENI FNENI
230 syn keyword masmOpFloat FFREE FIADD FICOM FICOMP FIDIV FIDIVR FILD
231 syn keyword masmOpFloat FIMUL FINCSTP FINIT FNINIT FIST FISTP FISUB
232 syn keyword masmOpFloat FISUBR FLD FLDCW FLDENV FLDLG2 FLDLN2 FLDL2E
233 syn keyword masmOpFloat FLDL2T FLDPI FLDZ FLD1 FMUL FMULP FNOP FPATAN
234 syn keyword masmOpFloat FPREM FPREM1 FPTAN FRNDINT FRSTOR FSAVE FNSAVE
235 syn keyword masmOpFloat FSCALE FSETPM FSIN FSINCOS FSQRT FST FSTCW
236 syn keyword masmOpFloat FNSTCW FSTENV FNSTENV FSTP FSTSW FNSTSW FSUB
237 syn keyword masmOpFloat FSUBP FSUBR FSUBRP FTST FUCOM FUCOMP FUCOMPP
238 syn keyword masmOpFloat FWAIT FXAM FXCH FXTRACT FYL2X FYL2XP1
240 " Floating-point opcodes in Pentium and later processors
241 syn keyword masmOpFloat FCMOVE FCMOVNE FCMOVB FCMOVBE FCMOVNB FCMOVNBE
242 syn keyword masmOpFloat FCMOVU FCMOVNU FCOMI FUCOMI FCOMIP FUCOMIP
243 syn keyword masmOpFloat FXSAVE FXRSTOR
245 " MMX opcodes (Pentium w/ MMX, Pentium II, and later)
246 syn keyword masmOpcode MOVD MOVQ PACKSSWB PACKSSDW PACKUSWB
247 syn keyword masmOpcode PUNPCKHBW PUNPCKHWD PUNPCKHDQ
248 syn keyword masmOpcode PUNPCKLBW PUNPCKLWD PUNPCKLDQ
249 syn keyword masmOpcode PADDB PADDW PADDD PADDSB PADDSW PADDUSB PADDUSW
250 syn keyword masmOpcode PSUBB PSUBW PSUBD PSUBSB PSUBSW PSUBUSB PSUBUSW
251 syn keyword masmOpcode PMULHW PMULLW PMADDWD
252 syn keyword masmOpcode PCMPEQB PCMPEQW PCMPEQD PCMPGTB PCMPGTW PCMPGTD
253 syn keyword masmOpcode PAND PANDN POR PXOR
254 syn keyword masmOpcode PSLLW PSLLD PSLLQ PSRLW PSRLD PSRLQ PSRAW PSRAD
255 syn keyword masmOpcode EMMS
257 " SSE opcodes (Pentium III and later)
258 syn keyword masmOpcode MOVAPS MOVUPS MOVHPS MOVHLPS MOVLPS MOVLHPS
259 syn keyword masmOpcode MOVMSKPS MOVSS
260 syn keyword masmOpcode ADDPS ADDSS SUBPS SUBSS MULPS MULSS DIVPS DIVSS
261 syn keyword masmOpcode RCPPS RCPSS SQRTPS SQRTSS RSQRTPS RSQRTSS
262 syn keyword masmOpcode MAXPS MAXSS MINPS MINSS
263 syn keyword masmOpcode CMPPS CMPSS COMISS UCOMISS
264 syn keyword masmOpcode ANDPS ANDNPS ORPS XORPS
265 syn keyword masmOpcode SHUFPS UNPCKHPS UNPCKLPS
266 syn keyword masmOpcode CVTPI2PS CVTSI2SS CVTPS2PI CVTTPS2PI
267 syn keyword masmOpcode CVTSS2SI CVTTSS2SI
268 syn keyword masmOpcode LDMXCSR STMXCSR
269 syn keyword masmOpcode PAVGB PAVGW PEXTRW PINSRW PMAXUB PMAXSW
270 syn keyword masmOpcode PMINUB PMINSW PMOVMSKB PMULHUW PSADBW PSHUFW
271 syn keyword masmOpcode MASKMOVQ MOVNTQ MOVNTPS SFENCE
272 syn keyword masmOpcode PREFETCHT0 PREFETCHT1 PREFETCHT2 PREFETCHNTA
274 " SSE2 opcodes (Pentium 4 and later)
275 syn keyword masmOpcode MOVAPD MOVUPD MOVHPD MOVLPD MOVMSKPD MOVSD
276 syn keyword masmOpcode ADDPD ADDSD SUBPD SUBSD MULPD MULSD DIVPD DIVSD
277 syn keyword masmOpcode SQRTPD SQRTSD MAXPD MAXSD MINPD MINSD
278 syn keyword masmOpcode ANDPD ANDNPD ORPD XORPD
279 syn keyword masmOpcode CMPPD CMPSD COMISD UCOMISD
280 syn keyword masmOpcode SHUFPD UNPCKHPD UNPCKLPD
281 syn keyword masmOpcode CVTPD2PI CVTTPD2PI CVTPI2PD CVTPD2DQ
282 syn keyword masmOpcode CVTTPD2DQ CVTDQ2PD CVTPS2PD CVTPD2PS
283 syn keyword masmOpcode CVTSS2SD CVTSD2SS CVTSD2SI CVTTSD2SI CVTSI2SD
284 syn keyword masmOpcode CVTDQ2PS CVTPS2DQ CVTTPS2DQ
285 syn keyword masmOpcode MOVDQA MOVDQU MOVQ2DQ MOVDQ2Q PMULUDQ
286 syn keyword masmOpcode PADDQ PSUBQ PSHUFLW PSHUFHW PSHUFD
287 syn keyword masmOpcode PSLLDQ PSRLDQ PUNPCKHQDQ PUNPCKLQDQ
288 syn keyword masmOpcode CLFLUSH LFENCE MFENCE PAUSE MASKMOVDQU
289 syn keyword masmOpcode MOVNTPD MOVNTDQ MOVNTI
291 " SSE3 opcodes (Pentium 4 w/ Hyper-Threading and later)
292 syn keyword masmOpcode FISTTP LDDQU ADDSUBPS ADDSUBPD
293 syn keyword masmOpcode HADDPS HSUBPS HADDPD HSUBPD
294 syn keyword masmOpcode MOVSHDUP MOVSLDUP MOVDDUP MONITOR MWAIT
296 " Other opcodes in Pentium and later processors
297 syn keyword masmOpcode CMPXCHG8B CPUID UD2
298 syn keyword masmOpcode RSM RDMSR WRMSR RDPMC RDTSC SYSENTER SYSEXIT
299 syn match masmOpcode "CMOV\(P[EO]\|\(N\?\([ABGL]E\?\|[CEOPSZ]\)\)\)\>"
302 " Define the default highlighting.
303 " For version 5.7 and earlier: only when not done already
304 " For version 5.8 and later: only when an item doesn't have highlighting yet
305 if version >= 508 || !exists("did_masm_syntax_inits")
307 let did_masm_syntax_inits = 1
308 command -nargs=+ HiLink hi link <args>
310 command -nargs=+ HiLink hi def link <args>
313 " The default methods for highlighting. Can be overridden later
314 HiLink masmLabel PreProc
315 HiLink masmComment Comment
316 HiLink masmDirective Statement
318 HiLink masmOperator Type
319 HiLink masmOption Special
320 HiLink masmRegister Special
321 HiLink masmString String
322 HiLink masmText String
323 HiLink masmTitle Title
324 HiLink masmOpcode Statement
325 HiLink masmOpFloat Statement
327 HiLink masmHexadecimal Number
328 HiLink masmDecimal Number
329 HiLink masmOctal Number
330 HiLink masmBinary Number
331 HiLink masmFloatRaw Number
332 HiLink masmFloat Number
334 HiLink masmIdentifier Identifier
336 syntax sync minlines=50
341 let b:current_syntax = "masm"