The directive MACRO must be followed by a macro prototype statement on the next line. This tells the assembler the name of the macro and its parameters. A label is optional, but useful if calls of the macro may be labelled. Any number of parameters can be used; each must begin with `$' to distinguish them from ordinary program symbols.
MACRO
{$label} macroname {$parameter1}{,$parameter2}{,$parameter3}..
...code...
MEND
Within the macro body, $label, $parameter, etc., can be used in the same way as any other variables (seeLocal and global variables - GBL, LCL and SET, and section Variable substitution - $). They will be given new values each time the macro is called.
Sometimes a macro parameter or label needs to be appended by a value. The appended value should be separated by a dot, which the assembler will ignore once it has used it to recognise the end of the parameter and label. For example:
The end of the macro definition is signified by the MEND directive.There must be no un-closed WHILE/WEND loops or conditional assembly when the MEND directive is reached. Macro expansion terminates at MEND. However it can also be terminated with the MEXIT directive, which can be used in conjunction with WHILE/WEND or conditional assembly.
$label.$count
...{$parameter="default value"}
can be invoked as:
$lab xxxx $arg1,$arg2=5,$arg3
An omitted actual argument is given a null (empty string) value. To force use of the default value, use `|' as the actual argument.
Label xxxx val1,val2,val3