ARM Assembler Directives for Macro Definition (Windows Embedded CE 6.0)
1/5/2010
Macros are useful when you need a group of instructions or directives frequently.
The ARM assembler replaces the macro name with its definition.
Macros can contain calls to other macros, nested up to 255 levels.
Two directives define a macro, MACRO and MEND.
Syntax
MACRO
{$label} macroname {$parameter1}{,$parameter2}{,$parameter3}..
...code...
MEND
Remarks
A macro prototype statement must appear on the first line following the MACRO directive. The prototype tells the assembler the name of the macro, macroname, and its parameters.
A label is optional, but is useful if the macro defines internal labels.
Any number of parameters can be used. Each must begin with $ to distinguish it from ordinary program symbols.
Within the macro body, $label, $parameter, and so on, can be used in the same way as other variables.
The $label parameter is treated as another parameter to the macro. The macro describes which labels are defined where. The label does not represent the first instruction in the macro expansion.
For example, it is useful in a macro that uses several internal labels, such as a loop, to define each internal label as the base label with a different suffix.
Sometimes, a value appends a macro parameter or label. Separate the appended value by a dot. After the assembler recognizes the end of the parameter and label, the assembler ignores the dot. For example:
$label.1
$label.loop
$label.$count
Default values can be set for parameters by following them with an equal sign and the default value. If the default has a leading or trailing space, the whole value should appear in quotes, as shown in the following code example.
...{$parameter="default value"}
The MEND directive signifies the end of the macro definition. If the macro contains WHILE/WEND loops, or contains conditional assembly, the WHILE/WEND loop must close before execution reaches the MEND directive.
You can also terminate macro expansion with the MEXIT directive.