Macro Parameters/Substitution Symbols - Texas Instruments TMS320C54x User Manual

Digital signal processors
Table of Contents

Advertisement

Macro Parameters/Substitution Symbols

5.3 Macro Parameters/Substitution Symbols
5.3.1
Substitution Symbols
5-6
If you want to call a macro several times with different data each time, you can
assign parameters within the macro. The macro language supports a special
symbol, called a substitution symbol , which is used for macro parameters.
Macro parameters are substitution symbols that represent a character string.
These symbols can also be used outside of macros to equate a character
string to a symbol name.
Valid substitution symbols may be 32 characters long and must begin with a
letter . The remainder of the symbol can be a combination of alphanumeric
characters, underscores, and dollar signs.
Substitution symbols used as macro parameters are local to the macro they
are defined in. You can define up to 32 local substitution symbols (including
substitution symbols defined with the .var directive) per macro. For more
information about the .var directive, see subsection 5.3.7, Substitution
Symbols as Local Variables in Macros , on page 5-13.
During macro expansion, the assembler passes arguments by variable to the
macro parameters. The character-string equivalent of each argument is
assigned to the corresponding parameter. Parameters without corresponding
arguments are set to the null string. If the number of arguments exceeds the
number of parameters, the last parameter is assigned the character-string
equivalent of all remaining arguments.
If you pass a list of arguments to one parameter, or if you pass a comma or
semicolon to a parameter, you must enclose the arguments in quotation
marks.
At assembly time, the assembler replaces the substitution symbol with its
corresponding character string, then translates the source code into object
code.
Example 5–2 shows the expansion of a macro with varying numbers of
arguments.

Advertisement

Table of Contents
loading

Table of Contents