Macro argument grouping

To pass text including commas as a single macro argument, the Assembler supports a special syntax. This grouping starts with the [? prefix and ends with the ?] suffix. If the [? or ?] patterns occur inside of the argument text, they have to be in pairs. Alternatively, escape brackets, question marks and backward slashes with a backward slash as prefix.

Note: This escaping only takes place inside of [? ?] arguments. A backslash is only removed in this process if it is just before a bracket ([]), a question mark (?), or a second backslash (\).
Listing: Example macro definition

MyMacro:  MACRO
            DC    \1

          ENDM

MyMacro1: MACRO

            \1

          ENDM

The following listing shows the macro calls with rather complicated arguments:

Listing: Macro calls

MyMacro [?$10, $56?]
MyMacro [?"\[?"?]

MyMacro1 [?MyMacro  [?$10, $56?]?]

MyMacro1 [?MyMacro \[?$10, $56\?]?]

These macro calls expand to the following listing:

Listing: Macro expansion

DC    $10, $56
DC    "[?"

DC    $10, $56

DC    $10, $56

The Macro Assembler does also supports for compatibility with previous version's macro grouping with an angle bracket syntax, as in the following listing:

Listing: Angle bracket syntax


      MyMacro <$10, $56>

However, this old syntax is ambiguous as < and > are also used as compare operators. For example, the following code does not produce the expected result:

Listing: Potential problem using the angle-bracket syntax


      MyMacro <1 > 2, 2 > 3> ; Wrong!

Because of this the old angle brace syntax should be avoided in new code. There is also and option to disable it explicitly.

See also the -CMacBrackets: Square brackets for macro arguments grouping and the -CMacAngBrack: Angle brackets for grouping Macro Arguments assembler options.