0001
0002
0003
0004
0005 #ifndef ASSEMBLER_H
0006 #define ASSEMBLER_H
0007
0008 .macro __for from:req, to:req
0009 .if (\from) == (\to)
0010 _for__body %\from
0011 .else
0012 __for \from, %(\from) + ((\to) - (\from)) / 2
0013 __for %(\from) + ((\to) - (\from)) / 2 + 1, \to
0014 .endif
0015 .endm
0016
0017 .macro _for var:req, from:req, to:req, insn:vararg
0018 .macro _for__body \var:req
0019 .noaltmacro
0020 \insn
0021 .altmacro
0022 .endm
0023
0024 .altmacro
0025 __for \from, \to
0026 .noaltmacro
0027
0028 .purgem _for__body
0029 .endm
0030
0031 .macro function name
0032 .macro endfunction
0033 .type \name, @function
0034 .purgem endfunction
0035 .endm
0036 \name:
0037 .endm
0038
0039 .macro define_accessor name, num, insn
0040 .macro \name\()_entry n
0041 \insn \n, 1
0042 ret
0043 .endm
0044
0045 function \name
0046 adr x2, .L__accessor_tbl\@
0047 add x2, x2, x0, lsl #3
0048 br x2
0049
0050 .L__accessor_tbl\@:
0051 _for x, 0, (\num) - 1, \name\()_entry \x
0052 endfunction
0053
0054 .purgem \name\()_entry
0055 .endm
0056
0057
0058
0059 .macro puts string
0060 .pushsection .rodata.str1.1, "aMS", 1
0061 .L__puts_literal\@: .string "\string"
0062 .popsection
0063
0064 ldr x0, =.L__puts_literal\@
0065 bl puts
0066 .endm
0067
0068 #endif