User’s Manual MCUez HC12 Assembler
206 Macros MOTOROLA
MacrosArguments in the operand field of the macro call refer to parameter designators
\1 through \9 and \A through \Z, in that order. The argument list (operand field)
of a macro call cannot be extended onto additional lines.
At the time of a macro call, arguments from the macro call are substituted with
parameter designators in the body of the macro as literal (string) substitutions.
The string corresponding to a given argument is substituted literally wherever
that parameter designator occurs in a source statement as the macro is expanded.
Each statement generated is assembled inline.
It is possible to specify a null argument in a macro call by inserting a comma
with no character (no space character) between the comma and the preceding
macro name or comma that follows an argument. When a null argument is
passed as an argument in a nested macro call, a null value is passed. All
arguments have a default value of null at the time of a macro call.
9.7 Labels Inside MacrosTo avoid the problem of multiple-defined labels resulting from multiple calls to
a macro that has labels in its source statements, the programmer can direct the
assembler to generate unique labels on each call to a macro.
Assembler-generated labels include a string of the form _nnnnn where nnnnn is
a 5-digit value. The programmer requests an assembler-generated label by
specifying \@ in a label field within a macro body. Each successive label
definition that specifies a \@ directive generates a successive value of _nnnnn,
thereby creating a unique label on each macro call.
NOTE:
\@ may be preceded or followed by additional characters for clarity and to
prevent ambiguity.
Example:
clear: MACRO
LDX \1
LDAB #16
\@LOOP: CLR 0,X
INX
DECB
BNE \@LOOP
ENDM