MOTOROLA
DSP ASSEMBLER REFERENCE MANUAL
For More Information On This Product,
Go to: www.freescale.com
5-1
Chapter 5
MACRO OPERATIONS AND CONDITIONAL ASSEMBLY
5.1
MACRO OPERATIONS
Programming applications frequently involve the coding of a repeated pattern or group of
instructions. Some patterns contain variable entries which change for each repetition of
the pattern. Others are subject to conditional assembly for a given occurrence of the in-
struction group. In either case, macros provide a shorthand notation for handling these
instruction patterns. Having determined the iterated pattern, the programmer can, within
the macro, designate selected fields of any statement as variable. Thereafter by invoking
a macro the programmer can use the entire pattern as many times as needed, substituting
different parameters for the designated variable portions of the statements.
When the pattern is defined it is given a name. This name becomes the mnemonic by
which the macro is subsequently invoked (called). If the name of the macro is the same
as an existing Assembler directive or mnemonic opcode, the macro will replace the direc-
tive or mnemonic opcode, and a warning will be issued. The warning can be avoided by
the use of the
RDIRECT
directive, which is used to remove entries from the Assembler’s
directive and mnemonic tables. If directives or mnemonics are removed from the Assem-
bler’s tables, then no warning will be issued when the Assembler processes macros
whose names are the same as the removed directive or mnemonic entries. However, if
a macro is defined through the
MACLIB
directive which has the same name as an existing
directive or opcode, it will not automatically replace that directive or opcode as previously
described. In this case, the
RDIRECT
directive must be used to force the replacement.
See the description of the
MACLIB
directive below.
The macro call causes source statements to be generated. The generated statements
may contain substitutable arguments. The statements produced by a macro call are rel-
atively unrestricted as to type. They can be any processor instruction, almost any Assem-
bler directive, or any previously-defined macro. Source statements resulting from a
macro call are subject to the same conditions and restrictions that are applied to state-
ments written by the programmer.
To invoke a macro, the macro name must appear in the operation code field of a source
statement. Any arguments are placed in the operand field. By suitably selecting the ar-
guments in relation to their use as indicated by the macro definition, the programmer
causes the Assembler to produce in-line coding variations of the macro definition.
F
Freescale Semiconductor, Inc.
n
.