Directives Reference
ARM DUI 0068B Copyright © 2000, 2001 ARM Limited. All rights reserved. 7-27
7.4.2 MACRO and MEND
The
MACRO
directive marks the start of the definition of a macro. Macro expansion
terminates at the
MEND
directive. See Using macros on page 2-48 for further information.
Syntax
Two directives are used to define a macro. The syntax is:
MACRO
{$label} macroname {$parameter{,$parameter}...}
; code
MEND
where:
$label
is a parameter that is substituted with a symbol given when the
macro is invoked. The symbol is usually a label.
macroname
is the name of the macro. It must not begin with an instruction or
directive name.
$parameter
is a parameter that is substituted when the macro is invoked. A
default value for a parameter can be set using this format:
$parameter="default value"
Double quotes must be used if there are any spaces within, or at
either end of, the default value.
Usage
If you start any
WHILE...WEND
loops or
IF...ENDIF
conditions within a macro, they must
be closed before the
MEND
directive is reached. See MEXIT on page 7-29 if you need to
allow an early exit from a macro, for example from within a loop.
Within the macro body, parameters such as
$label
,
$parameter
can be used in the same
way as other variables (see Assembly time substitution of variables on page 3-14). They
are given new values each time the macro is invoked. Parameters must begin with
$
to
distinguish them from ordinary symbols. Any number of parameters can be used.
$label
is optional. It is useful if the macro defines internal labels. It is treated as a
parameter to the macro. It does not necessarily represent the first instruction in the
macro expansion. The macro defines the locations of any labels.