Macro Operations And Conditional Assembly
Macro Libraries
5-2
DSP ASSEMBLER REFERENCE MANUAL
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
The effect of a macro call is to produce in-line code to perform a predefined function. The
code is inserted in the normal flow of the program so that the generated instructions are
executed with the rest of the program each time the macro is called.
An important feature in defining a macro is the use of macro calls within the macro defini-
tion. The Assembler processes such
nested
macro calls at expansion time only. The
nesting of one macro definition within another definition is permitted. However, the nested
macro definition will not be processed until the primary macro is expanded. The macro
must be defined before its appearance in a source statement operation field.
5.2
MACRO LIBRARIES
The Motorola DSP Assembler allows for the maintenance of macro libraries with the
MA-
CLIB
directive. This directive is used to specify the pathname (as defined by the host op-
erating system) of a directory that contains macro definitions. Each macro definition must
be in a separate file, and the file must be named the same as the macro with the extension
.ASM added. For example, BLOCKMV.ASM would be a file that contained the definition
of the macro called BLOCKMV.
If a
MACLIB
directive has been specified in the source code and the Assembler encoun-
ters a name in the operation field that is not a previously defined macro or is not contained
in the directive or mnemonic tables, the directory specified in the
MACLIB
directive will be
searched for a file of that name (with the .ASM extension added). If such a file is found,
the current source line will be saved, and the file will be opened for input as an
INCLUDE
file. When the end of the file is encountered, the source line is restored and processing
is resumed.
Because the source line is restored, the processed file must have a macro definition of the
unknown name, or an error will result when the source line is restored and processed.
However, the processed file is not limited to macro definitions, and can include any legal
source code statements. Multiple
MACLIB
directives may be given, in which case the As-
sembler will search each directory in the order in which they were specified.
5.3
MACRO DEFINITION
The definition of a macro consists of three parts: the header, which assigns a name to the
macro and defines the dummy arguments; the body, which consists of prototype or skel-
eton source statements; and the terminator. The header is the
MACRO
directive, its label,
and the dummy argument list. The body contains the pattern of standard source state-
ments. The terminator is the
ENDM
directive.
The header of a macro definition has the form:
<label>
MACRO
[<dummy argument list>][<comment>]
F
Freescale Semiconductor, Inc.
n
.