You can give a sequence of characters a symbolic name and then use the name in place of the text later in the source code. The named text is called a text macro.
The syntax for defining a text macro is
nameTEXTEQU <text>
nameTEXTEQU macroId |textmacro
nameTEXTEQU %constExpr
where text is a sequence of characters enclosed in angle brackets, macroId is a previously defined macro function (see Section 9.6), textmacro is a previously defined text macro, and %constExpr is an expression that evaluates to text. The use of angle brackets to delimit text is discussed in more detail in Section 9.3.1, and the % operator is explained in Section 9.3.2.
Here are some examples:
msg TEXTEQU <Some text> ; Text assigned to symbol
string TEXTEQU msg ; Text macro assigned to symbol
msg TEXTEQU <Some other text> ; New text assigned to symbol
value TEXTEQU %(3 + num) ; Text representation of
; resolved expression assigned
; to symbol
In the first line, text is assigned to the symbol msg. In the second line, the text of the msg text macro is assigned to a new text macro called string. In the third line, new text is assigned to msg. The result is that msg has the new text value, while string has the original text value. The fourth line assigns 7 to value if num equals 4. If a text macro expands to another text macro (or macro function, which is discussed in Section 9.6), the resulting text macro will be recursively expanded.
Text macros are useful for naming strings of text that do not evaluate to integers. For example, you might use a text macro to name a floating-point constant or a bracketed expression. Here are some practical examples:
pi TEXTEQU <3.1416> ; Floating point constant
WPT TEXTEQU <WORD PTR> ; Sequence of key words
arg1 TEXTEQU <[bp+4]> ; Bracketed expression
NOTE:
Use of the TEXTEQU directive to define text macros is new in MASM 6.0. In previous versions, you can use the EQU directive for the same purpose. If you have old code that worked under previous versions, it should still work under 6.0. However, the more consistent and flexible TEXTEQU is recommended for new code.