|
III.11.1 Simple Callable Macros
Macros must first be defined, before they can be called in a program.
A simple macro definition consists of the macro name, which can be defined
with the keyword MACRO, the macro body, and a final ENDM (end macro)
instruction.
<macro name> MACRO
<body line 1>
<body line 2>
.
.
<body line m>
ENDM
The macro name must be a valid, unique symbol. It cannot be redefined later.
Keywords cannot be used as macro names.
The macro body may comprise any number of lines. Body lines may be all kinds
of assembler instructions, pseudo instructions, controls, meta instructions,
macro calls and even further macro definitions.
The macro body and the whole macro definition is terminated with the ENDM
instruction.
Macros must be defined, before they can be called. Forward references to
macros are not allowed. Once defined, a macro can be called by its name in
the subsequent program as often as desired. Whenever a macro is called, the
macro body will be "inserted" into the program and then assembled as normal
source lines. This process is called macro expansion.
Example:
MY_FIRST MACRO ;definition
MOV A,#42
ADD A,R5
ENDM
MY_FIRST ;call
After the call of the macro MY_FIRST, the body lines
MOV A,#42
ADD A,R5
are inserted into the program and assembled.
|