Invoking Macros

To invoke a macro, use its name in your assembler listing, separating parameters with commas. To pass a parameter that includes a comma, enclose the parameter in angle brackets.

For example, Pattern Macro Definition shows macro pattern, which repeats a pattern of bytes passed to it the number of times specified in the macro call. Macro Argument with Commas shows a statement that calls pattern, passing a parameter that includes a comma. Alternate Byte-Pattern Method is another example calling statement; the assembler generates the same code in response to the calling statement of either Macro Argument with Commas or Alternate Byte-Pattern Method.

Listing 1. Pattern Macro Definition
pattern:    .macro times,bytes
                .rept times

                .byte bytes

                .endr

            .endm
Listing 2. Macro Argument with Commas
            .data
halfgrey:   pattern 4,<0xAA,0x55>
Listing 3. Alternate Byte-Pattern Method
halfgrey:   .byte 0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55