In writing macros, you will often assign and modify values assigned to symbols. These symbols can be thought of as assembly-time variables. Like memory variables, they are symbols that represent values. But since macros are processed at assembly time, any symbol modified in a macro must be resolved as a constant by the end of assembly.
The three kinds of assembly-time variables are:
Macro parameters
Text macros
Macro functions
When a macro is expanded, the symbols are processed in the order shown above. First macro parameters are replaced with the text of their actual arguments. Then text macros are expanded.
Macro parameters are similar to procedure parameters in some ways, but they also have important differences. In a procedure, a parameter has a type and a memory location. Its value can be modified within the procedure. In a macro, a parameter is a placeholder for the argument text. The value can only be assigned to another symbol or used directly; it cannot be modified. The macro may interpret the argument text it receives either as a numeric value or as a text value.
It is important to understand the difference between text values and numeric values. Numeric values can be processed with arithmetic operators and assigned to numeric equates. Text values can be processed with macro functions and assigned to text macros.
Macro operators are often helpful when processing assembly-time variables. Table 9.1 shows the macro operators that MASM provides:
Table 9.1 MASM Macro Operators
Symbol | Name | Description |
< > | Text Delimiters | Opens and closes a literal string. |
! | Literal-Character Operator | Treats the next character as a literal character, even if it would normally have another meaning. |
% | Expansion Operator | Causes the assembler to expand a constant expression or text macro. |
& | Substitution Operator | Tells the assembler to replace a macro parameter or text macro name with its actual value. |
The next sections explain these operators in detail.