Macro Operations And Conditional Assembly
Macro Calls
5-4
DSP ASSEMBLER REFERENCE MANUAL
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
When specifying a local label within the body of a macro, the programmer must be aware
that the label symbol is valid for the entire body of the current level of macro expansion.
It is not valid for any nested macros within the current level of expansion. The example
above shows why the local label feature is useful. If the macro N_R_MUL were called
several times, there would be several _ENDLOOP labels resulting from the macro expan-
sions. This is acceptable because each _ENDLOOP label is considered private to a par-
ticular instance of macro expansion.
It is sometimes desirable to pass local labels as macro arguments to be used within the
macro as address references (e.g. MOVE #_LABEL,R0). The Assembler effectively dis-
allows this, however, since underscore label references within a macro invocation are re-
garded as labels local to that expansion of the macro. A macro local label override is
provided which causes local symbol lookup to have normal scope rather than macro call
scope. If a circumflex (
^
) precedes an expression containing an underscore label, at ex-
pansion the associated term will be evaluated using the normal local label list rather than
the macro local label list. The operator has no effect on normal labels or outside a macro
expansion.
5.4
MACRO CALLS
When a macro is invoked the statement causing the action is termed a
macro call
. The
syntax of a macro call consists of the following fields:
[<label>] <macro name> [<arguments>][<comment>]
The argument field can have the form:
[<arg>[,<arg>,...,<arg>]]
The macro call statement is made up of three fields besides the comment field: the <la-
bel>, if any, will correspond to the value of the location counter at the start of the macro
expansion; the operation field which contains the macro name; and the operand field
which contains substitutable arguments. Within the operand field each calling argument
of a macro call corresponds one-to-one with a dummy argument of the macro definition.
For example, the N_R_MUL macro defined earlier could be invoked for expansion (called)
by the statement:
N_R_MUL
CNT+1,VEC1,VEC2,OUT
where the operand field arguments, separated by commas and taken left to right, corre-
spond to the dummy arguments "N" through "RESULT", respectively. These arguments
are then substituted in their corresponding positions of the definition to produce a se-
quence of instructions.
Macro arguments consist of sequences of characters separated by commas. Although
these can be specified as quoted strings, to simplify coding the Assembler does not re-
quire single quotes around macro argument strings. However, if an argument has an em-
bedded comma or space, that argument must be surrounded by single quotes ('). An
F
Freescale Semiconductor, Inc.
n
.