tree-sitter-m68k
Version:
Motorola 68000 family assembly grammar for tree-sitter
389 lines (374 loc) • 8.48 kB
Plain Text
============================================
Labels
============================================
label:
label: rts
label:rts
.label:
.label.label:
.label$:
label
label rts
label:
label: rts
label::
label::
(source_file
(label name: (symbol))
(label name: (symbol))
(instruction mnemonic: (instruction_mnemonic))
(label name: (symbol))
(instruction mnemonic: (instruction_mnemonic))
(label name: (symbol))
(label name: (symbol))
(label name: (symbol))
(label name: (symbol))
(label name: (symbol))
(instruction mnemonic: (instruction_mnemonic))
(label name: (symbol))
(label name: (symbol))
(instruction mnemonic: (instruction_mnemonic))
(external_label name: (symbol))
(external_label name: (symbol))
)
============================================
Comments
============================================
; Comment
label ; Comment
move d1,d2 ; Comment
* Comment
label * Comment
move d1,d2 * Comment
move d1, d2 foo bar baz
(source_file
(comment)
(label (symbol))
(comment)
(instruction
(instruction_mnemonic)
(operand_list
(data_register)
(data_register)))
(comment)
(comment)
(label (symbol))
(comment)
(instruction
(instruction_mnemonic)
(operand_list
(data_register)
(data_register)))
(comment)
(instruction
(instruction_mnemonic)
(operand_list
(data_register)
(data_register)))
(comment)
)
============================================
Instructions
============================================
rts
lsl d0
move d0,d1
move.w d0,d1
MoVe.W D0,d1
move d0 , d1
move d0,d1,
(source_file
(instruction mnemonic: (instruction_mnemonic))
(instruction
mnemonic: (instruction_mnemonic)
operands: (operand_list
(data_register)))
(instruction
mnemonic: (instruction_mnemonic)
operands: (operand_list
(data_register)
(data_register)))
(instruction
mnemonic: (instruction_mnemonic)
size: (size)
operands: (operand_list
(data_register)
(data_register)))
(instruction
mnemonic: (instruction_mnemonic)
size: (size)
operands: (operand_list
(data_register)
(data_register)))
(instruction
mnemonic: (instruction_mnemonic)
operands: (operand_list
(data_register)
(data_register)))
(instruction
mnemonic: (instruction_mnemonic)
operands: (operand_list
(data_register)
(data_register)))
)
============================================
Label scope
============================================
move global_label\.local_label,d0
move global_label\\.local_label,d0
(source_file
(instruction
(instruction_mnemonic)
(operand_list
(symbol)
(data_register)))
(instruction
(instruction_mnemonic)
(operand_list
(symbol)
(data_register)))
)
============================================
Macro calls
============================================
MyMacro
MyMacro d0,d1
MyMacro.b d0,d1
MyMacro."1" d0,d1
MyMacro.\1 d0,d1
MyMacro <1,"foo">,d1
%getdate 3
foo: MyMacro d0,d1
bar: MyMacro
baz: MyMacro d0,d1 ; example
woo: MyMacro ; example
(source_file
(macro_call (symbol))
(macro_call
(symbol)
(argument_list
(data_register)
(data_register)))
(macro_call
(symbol)
(symbol)
(argument_list
(data_register)
(data_register)))
(macro_call
(symbol)
(string_literal)
(argument_list
(data_register)
(data_register)))
(macro_call
(symbol)
(macro_arg)
(argument_list
(data_register)
(data_register)))
(macro_call
(symbol)
(argument_list
(quoted_arg
(decimal_literal)
(string_literal))
(data_register)))
(macro_call
(symbol)
(argument_list
(decimal_literal)))
(label
(symbol))
(macro_call
(symbol)
(argument_list
(data_register)
(data_register)))
(label
(symbol))
(macro_call
(symbol))
(label
(symbol))
(macro_call
(symbol)
(argument_list
(data_register)
(data_register)))
(comment)
(label
(symbol))
(macro_call
(symbol))
(comment))
============================================
Generic Directives
============================================
even
echo "example"
(source_file
(directive mnemonic: (directive_mnemonic))
(directive
mnemonic: (directive_mnemonic)
operands: (operand_list
(string_literal)))
)
============================================
Options
============================================
opt o+,ol+,op+
(source_file
(opt
mnemonic: (directive_mnemonic)
options: (option_list
(option)
(option)
(option)))
)
============================================
Sections
============================================
section "example"
section example
section example,code
section example,code_f
section example,code,fast
code_f
section example,code,1
(source_file
(section (directive_mnemonic) name: (string_literal))
(section (directive_mnemonic) name: (symbol))
(section (directive_mnemonic) name: (symbol) type: (section_type))
(section (directive_mnemonic) name: (symbol) type: (section_type))
(section (directive_mnemonic) name: (symbol) type: (section_type) memory_type: (memory_type))
(section type: (section_type))
(section (directive_mnemonic) name: (symbol) type: (section_type) memory_type: (decimal_literal))
)
============================================
Include
============================================
include foo/bar.s
include "foo/bar baz.s"
(source_file
(include (directive_mnemonic) path: (path))
(include (directive_mnemonic) path: (path (string_literal)))
)
============================================
Include directory
============================================
incdir foo/bar
incdir "foo/bar baz"
(source_file
(include_dir (directive_mnemonic) path: (path))
(include_dir (directive_mnemonic) path: (path (string_literal)))
)
============================================
Include binary
============================================
incbin foo/bar.bin
incbin "foo/bar baz.bin"
incbin foo/bar.bin,100
incbin foo/bar.bin,100,200
(source_file
(include_bin (directive_mnemonic) path: (path))
(include_bin (directive_mnemonic) path: (path (string_literal)))
(include_bin (directive_mnemonic) path: (path) offset: (decimal_literal))
(include_bin (directive_mnemonic) path: (path) offset: (decimal_literal) length: (decimal_literal))
)
============================================
Data constant
============================================
dc.b 1,2,3
dc.b "foo bar",2,3
db 1,2,3
dw 1,2,3
dl 1,2,3
(source_file
(data_constant
mnemonic: (directive_mnemonic)
size: (size)
values: (expression_list
(decimal_literal)
(decimal_literal)
(decimal_literal)))
(data_constant
mnemonic: (directive_mnemonic)
size: (size)
values: (expression_list
(string_literal)
(decimal_literal)
(decimal_literal)))
(data_constant
mnemonic: (directive_mnemonic)
values: (expression_list
(decimal_literal)
(decimal_literal)
(decimal_literal)))
(data_constant
mnemonic: (directive_mnemonic)
values: (expression_list
(decimal_literal)
(decimal_literal)
(decimal_literal)))
(data_constant
mnemonic: (directive_mnemonic)
values: (expression_list
(decimal_literal)
(decimal_literal)
(decimal_literal)))
)
============================================
Data space
============================================
dcb 1
dcb.b 1
dcb.b 1,2
DCB.B 1,2
blk.b 1,2
ds 1
ds.b 1
(source_file
(data_space
mnemonic: (directive_mnemonic)
length: (decimal_literal))
(data_space
mnemonic: (directive_mnemonic)
size: (size)
length: (decimal_literal))
(data_space
mnemonic: (directive_mnemonic)
size: (size)
length: (decimal_literal)
fill: (decimal_literal))
(data_space
mnemonic: (directive_mnemonic)
size: (size)
length: (decimal_literal)
fill: (decimal_literal))
(data_space
mnemonic: (directive_mnemonic)
size: (size)
length: (decimal_literal)
fill: (decimal_literal))
(data_space
mnemonic: (directive_mnemonic)
length: (decimal_literal))
(data_space
mnemonic: (directive_mnemonic)
size: (size)
length: (decimal_literal))
)