The commands .MACRO and .ENDM allow you to define macros
that generate assembly output. You can use these macros with a syntax
similar to built-in GASP or assembler directives. For example,
this definition specifies a macro SUM that adds together a range of
consecutive registers:
.MACRO SUM FROM=0, TO=9
! \FROM \TO
mov r\FROM,r10
COUNT .ASSIGNA \FROM+1
.AWHILE \&COUNT LE \TO
add r\&COUNT,r10
COUNT .ASSIGNA \&COUNT+1
.AENDW
.ENDM
With that definition, `SUM 0,5' generates this assembly output:
! 0 5
mov r0,r10
add r1,r10
add r2,r10
add r3,r10
add r4,r10
add r5,r10
.MACRO macname
.MACRO macname macargs ...
.MACRO statements:
.MACRO COMM
COMM, which takes no
arguments.
.MACRO PLUS1 P, P1
.MACRO PLUS1 P P1
PLUS1,
which takes two arguments; within the macro definition, write
`\P' or `\P1' to evaluate the arguments.
.MACRO RESERVE_STR P1=0 P2
RESERVE_STR, with two
arguments. The first argument has a default value, but not the second.
After the definition is complete, you can call the macro either as
`RESERVE_STR a,b' (with `\P1' evaluating to
a and `\P2' evaluating to b), or as `RESERVE_STR
,b' (with `\P1' evaluating as the default, in this case
`0', and `\P2' evaluating to b).
name .MACRO
name .MACRO ( macargs ... )
.ENDM
.EXITM
.AREPEAT loop, or
.AWHILE loop.
\@
LOCAL name [ , ... ]
LOCAL is only available if you select "alternate
macro syntax" with `-a' or `--alternate'. See section Alternate macro syntax.
Generate a string replacement for each of the name arguments, and
replace any instances of name in each macro expansion. The
replacement string is unique in the assembly, and different for each
separate macro expansion. LOCAL allows you to write macros that
define symbols, without fear of conflict between separate macro expansions.