The changes to macro functionality in MASM 6.0 are also significant. New directives provide for a variable number of arguments, loop constructions, definitions of text equates, and macro functions.
In MASM 5.1, extra arguments passed to macros are ignored. In MASM 6.0, you can pass a variable number of arguments to a macro by appending the VARARG keyword to the last macro parameter in the macro definition. Additional arguments passed to this macro can then be referenced relative to the last declared parameter. Section 9.6, “Returning Values with Macro Functions,” explains how to do this.
Required and Default Macro Arguments
With MASM 6.0, you can use REQ or the := operator to specify required or default arguments. See Section 9.2.3.
New Directives for Macro Loops
Within a macro definition, WHILE repeats assembly as long as a condition remains true. Other macro loop directives, IRP, IRPC, and REPT, have been renamed FOR, FORC, and REPEAT. For more information, see Section 9.4, “Defining Repeat Blocks with Loop Directives.”
You should use the EQU directive to define numeric constants, but MASM 6.0 also has a new TEXTEQU directive for defining text macros. TEXTEQU allows greater functionality than EQU. For example, it can assign the value calculated by a macro function to a label. For more information, see Section 9.1, “Text Macros.”
Within a macro definition, GOTO transfers assembly to a labeled line. Lines in macros can be labeled using a leading colon(:). The GOTO directive can then be used to change the flow of control within that macro. See online help.
At assembly time, macro functions can determine and return a text value using EXITM. Predefined macro string functions concatenate strings, return the size of a string, find a substring in a string, and return the position of a substring within a string. For information on writing your own macro functions, see Section 9.6, “Returning Values with Macro Functions.”
The following predefined text macro functions are new:
Symbol | Value Returned |
@CatStr | A concatenated string |
@InStr | The position of one string within another |
@SizeStr | The size of a string |
@SubStr | A substring |
For more information, see Section 9.5, “String Directives and Predefined Functions.”