| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " Vim syntax file | 
					
						
							|  |  |  | " Language:	GNU Assembler | 
					
						
							| 
									
										
										
										
											2010-01-12 21:31:21 +01:00
										 |  |  | " Maintainer:	Erik Wognsen <erik.wognsen@gmail.com> | 
					
						
							|  |  |  | "		Previous maintainer: | 
					
						
							|  |  |  | "		Kevin Dahlhausen <kdahlhaus@yahoo.com> | 
					
						
							| 
									
										
										
										
											2014-02-11 19:15:50 +01:00
										 |  |  | " Last Change:	2014 Feb 04 | 
					
						
							| 
									
										
										
										
											2010-05-14 23:24:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | " Thanks to Ori Avtalion for feedback on the comment markers! | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | " quit when a syntax file was already loaded | 
					
						
							|  |  |  | if exists("b:current_syntax") | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-10 14:55:01 +01:00
										 |  |  | let s:cpo_save = &cpo | 
					
						
							|  |  |  | set cpo&vim | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | syn case ignore | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " storage types | 
					
						
							|  |  |  | syn match asmType "\.long" | 
					
						
							|  |  |  | syn match asmType "\.ascii" | 
					
						
							|  |  |  | syn match asmType "\.asciz" | 
					
						
							|  |  |  | syn match asmType "\.byte" | 
					
						
							|  |  |  | syn match asmType "\.double" | 
					
						
							|  |  |  | syn match asmType "\.float" | 
					
						
							|  |  |  | syn match asmType "\.hword" | 
					
						
							|  |  |  | syn match asmType "\.int" | 
					
						
							|  |  |  | syn match asmType "\.octa" | 
					
						
							|  |  |  | syn match asmType "\.quad" | 
					
						
							|  |  |  | syn match asmType "\.short" | 
					
						
							|  |  |  | syn match asmType "\.single" | 
					
						
							|  |  |  | syn match asmType "\.space" | 
					
						
							|  |  |  | syn match asmType "\.string" | 
					
						
							|  |  |  | syn match asmType "\.word" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match asmLabel		"[a-z_][a-z0-9_]*:"he=e-1 | 
					
						
							|  |  |  | syn match asmIdentifier		"[a-z_][a-z0-9_]*" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Various #'s as defined by GAS ref manual sec 3.6.2.1 | 
					
						
							|  |  |  | " Technically, the first decNumber def is actually octal, | 
					
						
							|  |  |  | " since the value of 0-7 octal is the same as 0-7 decimal, | 
					
						
							| 
									
										
										
										
											2012-01-10 14:55:01 +01:00
										 |  |  | " I (Kevin) prefer to map it as decimal: | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | syn match decNumber		"0\+[1-7]\=[\t\n$,; ]" | 
					
						
							|  |  |  | syn match decNumber		"[1-9]\d*" | 
					
						
							|  |  |  | syn match octNumber		"0[0-7][0-7]\+" | 
					
						
							|  |  |  | syn match hexNumber		"0[xX][0-9a-fA-F]\+" | 
					
						
							|  |  |  | syn match binNumber		"0[bB][0-1]*" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-14 23:24:24 +02:00
										 |  |  | syn keyword asmTodo		contained TODO | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-10 14:55:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | " GAS supports one type of multi line comments: | 
					
						
							| 
									
										
										
										
											2010-05-14 23:24:24 +02:00
										 |  |  | syn region asmComment		start="/\*" end="\*/" contains=asmTodo | 
					
						
							| 
									
										
										
										
											2012-01-10 14:55:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-13 23:04:47 +02:00
										 |  |  | " GAS (undocumentedly?) supports C++ style comments. Unlike in C/C++ however, | 
					
						
							|  |  |  | " a backslash ending a C++ style comment does not extend the comment to the | 
					
						
							|  |  |  | " next line (hence the syntax region does not define 'skip="\\$"') | 
					
						
							|  |  |  | syn region asmComment		start="//" end="$" keepend contains=asmTodo | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-10 14:55:01 +01:00
										 |  |  | " Line comment characters depend on the target architecture and command line | 
					
						
							|  |  |  | " options and some comments may double as logical line number directives or | 
					
						
							|  |  |  | " preprocessor commands. This situation is described at | 
					
						
							|  |  |  | " http://sourceware.org/binutils/docs-2.22/as/Comments.html | 
					
						
							|  |  |  | " Some line comment characters have other meanings for other targets. For | 
					
						
							|  |  |  | " example, .type directives may use the `@' character which is also an ARM | 
					
						
							|  |  |  | " comment marker. | 
					
						
							|  |  |  | " As a compromise to accommodate what I arbitrarily assume to be the most | 
					
						
							|  |  |  | " frequently used features of the most popular architectures (and also the | 
					
						
							|  |  |  | " non-GNU assembly languages that use this syntax file because their asm files | 
					
						
							|  |  |  | " are also named *.asm), the following are used as line comment characters: | 
					
						
							| 
									
										
										
										
											2010-05-14 23:24:24 +02:00
										 |  |  | syn match asmComment		"[#;!|].*" contains=asmTodo | 
					
						
							| 
									
										
										
										
											2012-01-10 14:55:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | " Side effects of this include: | 
					
						
							|  |  |  | " - When `;' is used to separate statements on the same line (many targets | 
					
						
							|  |  |  | "   support this), all statements except the first get highlighted as | 
					
						
							|  |  |  | "   comments. As a remedy, remove `;' from the above. | 
					
						
							|  |  |  | " - ARM comments are not highlighted correctly. For ARM, uncomment the | 
					
						
							|  |  |  | "   following two lines and comment the one above. | 
					
						
							|  |  |  | "syn match asmComment		"@.*" contains=asmTodo | 
					
						
							|  |  |  | "syn match asmComment		"^#.*" contains=asmTodo | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Advanced users of specific architectures will probably want to change the | 
					
						
							|  |  |  | " comment highlighting or use a specific, more comprehensive syntax file. | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | syn match asmInclude		"\.include" | 
					
						
							|  |  |  | syn match asmCond		"\.if" | 
					
						
							|  |  |  | syn match asmCond		"\.else" | 
					
						
							|  |  |  | syn match asmCond		"\.endif" | 
					
						
							|  |  |  | syn match asmMacro		"\.macro" | 
					
						
							|  |  |  | syn match asmMacro		"\.endm" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 19:15:50 +01:00
										 |  |  | " Assembler directives start with a '.' and may contain upper case (e.g., | 
					
						
							|  |  |  | " .ABORT), numbers (e.g., .p2align), dash (e.g., .app-file) and underscore in | 
					
						
							|  |  |  | " CFI directives (e.g., .cfi_startproc). This will also match labels starting | 
					
						
							|  |  |  | " with '.', including the GCC auto-generated '.L' labels. | 
					
						
							|  |  |  | syn match asmDirective		"\.[A-Za-z][0-9A-Za-z-_]*" | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn case match | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Define the default highlighting. | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | " Only when an item doesn't have highlighting yet | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " The default methods for highlighting.  Can be overridden later | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link asmSection	Special | 
					
						
							|  |  |  | hi def link asmLabel	Label | 
					
						
							|  |  |  | hi def link asmComment	Comment | 
					
						
							|  |  |  | hi def link asmTodo	Todo | 
					
						
							|  |  |  | hi def link asmDirective	Statement | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link asmInclude	Include | 
					
						
							|  |  |  | hi def link asmCond	PreCondit | 
					
						
							|  |  |  | hi def link asmMacro	Macro | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link hexNumber	Number | 
					
						
							|  |  |  | hi def link decNumber	Number | 
					
						
							|  |  |  | hi def link octNumber	Number | 
					
						
							|  |  |  | hi def link binNumber	Number | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link asmIdentifier	Identifier | 
					
						
							|  |  |  | hi def link asmType	Type | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | let b:current_syntax = "asm" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-10 14:55:01 +01:00
										 |  |  | let &cpo = s:cpo_save | 
					
						
							|  |  |  | unlet s:cpo_save | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " vim: ts=8 |