blob: 6b8ce1ed5bda445c0c6de44b09bb92082c761470 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: GNU Assembler
Bram Moolenaar555cdc22010-01-12 21:31:21 +01003" Maintainer: Erik Wognsen <erik.wognsen@gmail.com>
4" Previous maintainer:
5" Kevin Dahlhausen <kdahlhaus@yahoo.com>
Bram Moolenaar00a927d2010-05-14 23:24:24 +02006" Last Change: 2010 Apr 18
7
8" Thanks to Ori Avtalion for feedback on the comment markers!
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10" For version 5.x: Clear all syntax items
Bram Moolenaar555cdc22010-01-12 21:31:21 +010011" For version 6.0 and later: Quit when a syntax file was already loaded
Bram Moolenaar071d4272004-06-13 20:20:40 +000012if version < 600
13 syntax clear
14elseif exists("b:current_syntax")
15 finish
16endif
17
18syn case ignore
19
Bram Moolenaar071d4272004-06-13 20:20:40 +000020" storage types
21syn match asmType "\.long"
22syn match asmType "\.ascii"
23syn match asmType "\.asciz"
24syn match asmType "\.byte"
25syn match asmType "\.double"
26syn match asmType "\.float"
27syn match asmType "\.hword"
28syn match asmType "\.int"
29syn match asmType "\.octa"
30syn match asmType "\.quad"
31syn match asmType "\.short"
32syn match asmType "\.single"
33syn match asmType "\.space"
34syn match asmType "\.string"
35syn match asmType "\.word"
36
37syn match asmLabel "[a-z_][a-z0-9_]*:"he=e-1
38syn match asmIdentifier "[a-z_][a-z0-9_]*"
39
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:
44syn match decNumber "0\+[1-7]\=[\t\n$,; ]"
45syn match decNumber "[1-9]\d*"
46syn match octNumber "0[0-7][0-7]\+"
47syn match hexNumber "0[xX][0-9a-fA-F]\+"
48syn match binNumber "0[bB][0-1]*"
49
Bram Moolenaar00a927d2010-05-14 23:24:24 +020050syn keyword asmTodo contained TODO
51
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
57syn region asmComment start="/\*" end="\*/" contains=asmTodo
58syn match asmComment "[#;!|].*" contains=asmTodo
59" syn match asmComment "@.*" contains=asmTodo
Bram Moolenaar071d4272004-06-13 20:20:40 +000060
61syn match asmInclude "\.include"
62syn match asmCond "\.if"
63syn match asmCond "\.else"
64syn match asmCond "\.endif"
65syn match asmMacro "\.macro"
66syn match asmMacro "\.endm"
67
68syn match asmDirective "\.[a-z][a-z]\+"
69
70
71syn case match
72
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
76if version >= 508 || !exists("did_asm_syntax_inits")
77 if version < 508
78 let did_asm_syntax_inits = 1
79 command -nargs=+ HiLink hi link <args>
80 else
81 command -nargs=+ HiLink hi def link <args>
82 endif
83
84 " The default methods for highlighting. Can be overridden later
85 HiLink asmSection Special
86 HiLink asmLabel Label
87 HiLink asmComment Comment
Bram Moolenaar00a927d2010-05-14 23:24:24 +020088 HiLink asmTodo Todo
Bram Moolenaar071d4272004-06-13 20:20:40 +000089 HiLink asmDirective Statement
90
91 HiLink asmInclude Include
92 HiLink asmCond PreCondit
93 HiLink asmMacro Macro
94
95 HiLink hexNumber Number
96 HiLink decNumber Number
97 HiLink octNumber Number
98 HiLink binNumber Number
99
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100 HiLink asmIdentifier Identifier
101 HiLink asmType Type
102
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103 delcommand HiLink
104endif
105
106let b:current_syntax = "asm"
107
108" vim: ts=8