Macro processing directives
Syntax
_args
ENDM
ENDMAC
ENDR
EXITM
LOCAL symbol [,symbol] …
name MACRO [argument] [,argument] …
REPT expr
REPTC formal,actual
REPTI formal,actual [,actual] …
Parameters
| Strings to be substituted. |
| Symbolic argument names. |
| An expression. |
| An argument into which each character of |
| The name of the macro. |
| Symbols to be local to the macro. |
Description
These directives allow user macros to be defined. For information about the restrictions that apply when using a directive in an expression, see Expression restrictions.
Directive | Description | Expression restrictions |
|---|---|---|
Is set to number of arguments passed to macro. | ||
Ends a macro definition. | ||
Ends a repeat structure. | ||
Exits prematurely from a macro. | ||
Creates symbols local to a macro. | ||
Defines a macro. | ||
Assembles instructions a specified number of times. | No forward references No external references Absolute Fixed | |
Repeats and substitutes characters. | ||
Repeats and substitutes text. |
A macro is a user-defined symbol that represents a block of one or more assembler source lines. Once you have defined a macro, you can use it in your program like an assembler directive or assembler mnemonic.
When the assembler encounters a macro, it looks up the macro’s definition, and inserts the lines that the macro represents as if they were included in the source file at that position.
Macros perform simple text substitution effectively, and you can control what they substitute by supplying parameters to them.
The macro process consists of three distinct phases:
The assembler scans and saves macro definitions. The text between
MACROandENDMis saved but not syntax checked.A macro call forces the assembler to invoke the macro processor (expander). The macro expander switches (if not already in a macro) the assembler input stream from a source file to the output from the macro expander. The macro expander takes its input from the requested macro definition.
The macro expander has no knowledge of assembler symbols since it only deals with text substitutions at source level. Before a line from the called macro definition is handed over to the assembler, the expander scans the line for all occurrences of symbolic macro arguments, and replaces them with their expansion arguments.
The expanded line is then processed as any other assembler source line. The input stream to the assembler continues to be the output from the macro processor, until all lines of the current macro definition have been read.