2 " Language: GNU Assembler
3 " Maintainer: Erik Wognsen <erik.wognsen@gmail.com>
5 " Kevin Dahlhausen <kdahlhaus@yahoo.com>
6 " Last Change: 2010 Apr 18
8 " Thanks to Ori Avtalion for feedback on the comment markers!
10 " For version 5.x: Clear all syntax items
11 " For version 6.0 and later: Quit when a syntax file was already loaded
14 elseif exists("b:current_syntax")
21 syn match asmType "\.long"
22 syn match asmType "\.ascii"
23 syn match asmType "\.asciz"
24 syn match asmType "\.byte"
25 syn match asmType "\.double"
26 syn match asmType "\.float"
27 syn match asmType "\.hword"
28 syn match asmType "\.int"
29 syn match asmType "\.octa"
30 syn match asmType "\.quad"
31 syn match asmType "\.short"
32 syn match asmType "\.single"
33 syn match asmType "\.space"
34 syn match asmType "\.string"
35 syn match asmType "\.word"
37 syn match asmLabel "[a-z_][a-z0-9_]*:"he=e-1
38 syn match asmIdentifier "[a-z_][a-z0-9_]*"
40 " Various #'s as defined by GAS ref manual sec 3.6.2.1
41 " Technically, the first decNumber def is actually octal,
42 " since the value of 0-7 octal is the same as 0-7 decimal,
43 " I prefer to map it as decimal:
44 syn match decNumber "0\+[1-7]\=[\t\n$,; ]"
45 syn match decNumber "[1-9]\d*"
46 syn match octNumber "0[0-7][0-7]\+"
47 syn match hexNumber "0[xX][0-9a-fA-F]\+"
48 syn match binNumber "0[bB][0-1]*"
50 syn keyword asmTodo contained TODO
52 " GAS supports various comment markers as described here:
53 " http://sourceware.org/binutils/docs-2.19/as/Comments.html
54 " I have commented out the ARM comment marker "@" by default as I think more
55 " people are using "@" with the .type directive. See
56 " http://sourceware.org/binutils/docs-2.19/as/Type.html
57 syn region asmComment start="/\*" end="\*/" contains=asmTodo
58 syn match asmComment "[#;!|].*" contains=asmTodo
59 " syn match asmComment "@.*" contains=asmTodo
61 syn match asmInclude "\.include"
62 syn match asmCond "\.if"
63 syn match asmCond "\.else"
64 syn match asmCond "\.endif"
65 syn match asmMacro "\.macro"
66 syn match asmMacro "\.endm"
68 syn match asmDirective "\.[a-z][a-z]\+"
73 " Define the default highlighting.
74 " For version 5.7 and earlier: only when not done already
75 " For version 5.8 and later: only when an item doesn't have highlighting yet
76 if version >= 508 || !exists("did_asm_syntax_inits")
78 let did_asm_syntax_inits = 1
79 command -nargs=+ HiLink hi link <args>
81 command -nargs=+ HiLink hi def link <args>
84 " The default methods for highlighting. Can be overridden later
85 HiLink asmSection Special
87 HiLink asmComment Comment
89 HiLink asmDirective Statement
91 HiLink asmInclude Include
92 HiLink asmCond PreCondit
95 HiLink hexNumber Number
96 HiLink decNumber Number
97 HiLink octNumber Number
98 HiLink binNumber Number
100 HiLink asmIdentifier Identifier
106 let b:current_syntax = "asm"