III.11.5 Macro Operators
There are some special control characters, which are very useful for macro
definition, call and expansion:
||Normally, comments in body lines are also contained in the expanded
lines. If a commentary begins with ';;' however, it is not stored
during macro definition. Therefore, it doesn't consume memory space,
and appears in the list file in the macro definition only, but not
in the expanded lines.
||If the escape character '!' precedes another printable character in
a macro argument, the assembler is forced to treat that character
literally. This means it will be passed to the macro, even if it is
a control character, while the literal operator itself is removed.
||If a macro argument is intended to contain separation or control
characters, it must be enclosed in literal brackets < ... > to pass
it to the macro as one argument string, while the outermost pair of
brackets is removed. Literal brackets can be nested to any depth.
||If a macro argument is preceded by the evaluation operator '%', it
is interpreted as an expression, which will be evaluated before it
is passed to the macro. The actual argument string will not be the
expression itself, but a decimal ASCII representation of its value.
The expression must be known on pass 1.
||The '&' character separates parameter names (local symbols) from
surrounding text. Outside quoted strings and commentary it serves
only as a general separation character. This applies always when
a local symbol directly precedes or follows another alphanumeric
string. Inside quoted strings and commentary, a local symbol must
be preceded by '&' if it is to be substituted there.
During every macro expansion, the assembler removes exactly one '&'
from every sequence of '&' characters. This allows for example, to
define a nested macro inside a macro body, which also uses the
substitution operator '&': one writes simply '&&'!
The commentary should only be visible in the definition
of the macro LICENSE:
DB 'Copyright' ;;legal stuff
When called, the expanded macro body is looking
like this in the list file:
passes a semicolon to the macro SPECIAL as a literal
argument. This could also be done with
The macro CONST defines a 16-bit constant in ROM:
CONST MACRO NUMB
If it is called as shown below,
the parameter NUMB would be substituted as follows:
If the same macro argument is preceded by a '%' however,
the substitution will result in:
During substitution, both arguments of the macro CONCAT
should form a seamless symbol name:
CONCAT MACRO NAM, NUM
NAM&NUM: DJNZ R3,NAM&NUM
When CONCAT is called as follows,
CONCAT LABEL, 08
the parameters NAM and NUM are substituted during macro
expansion as shown below:
LABEL08: DJNZ R3,LABEL08