("hdp rer 5.
Macros
Nested Macro Definitions
A macro definition can
be
contained completely within the,body
of
another macro definition (that
is,
macro
definitions can
be
nested). The body
of
a macro consists
of
all
text (including nested macro definitions)
hounded
by
matching MACRO and
ENDM
directives. The assembler allows any number
of
macro definitions to
be
nested.
When
a higher-level macro
is
called for expansion, the next lower-level macro
is
defined and eligible to be called
for expansion. A lower-level macro cannot
be
called unless
all
higher-level macro definitions have already been
called and expanded.
A new macro may
be
defined or an existing macro redefined
by
a nested macro definition depending on whether
the name of the nested macro i, a
new
label or has previously been established
as
a dummy parameter
in
a
!llghcr-level macro definition. Therefore, each time a higher-level macro
is
called, a lower-level definition can
be
ddined
difterently if the two contain common dummy parameter'>. Such redefinition can be costly, however,
in
tel
inS
01
assembler execution
,>peed.
Since IRP, IRPC, and REPT blocks con'>titute macro definitions, they also can
be
nested within another definition
Cleated
by
IRP, IRPC, REPT, or MACRO directive'>.
In
addition, an element
in
an IRP or IRPC actual parameter
li.,t
(enclosed
in
angle brackets) may itself
be
a list
of
bracketed parameters;
that
is,
lists
of
parameters can contain
elements that arc also lists.
Example:
LISTS
MACRO
PARAM1,PARAM2
EN
OM
MACRO
CALLS
Once a macro has been defined,
it
can
be
called any number
of
times
in
the program. The call consists
of
the
macro name and any actual parameters that are to replace dummy parameters during macro expansion. During
assembly, each macro call
is
replaced
by
the macro definition code; dummy parameters are replaced
by
actual
parameters.
Macro
Call
Format
Label
optional:
5·12
Opcode
macro name
Operand
optional actual
parameter(s)