Next: , Previous: , Up: Using the Assembler Preprocessor   [Contents][Index]


5.13.4 Defining Macros

A macro definition looks like this:

name    macro   arg1, arg2, ...
        text
        end     macro

The above code block defines a macro name with arguments arg1, arg2, ... A macro may have no arguments at all. The names of macro arguments work as the names of local symbols usable within the macro.

If a macro has a long list of arguments, you can split the list into multiple lines. To indicate that a line of a list of arguments continues on the next line, terminate a continued line with a comma after the name of an argument. The following example demonstrates this:

mac1    macro   arg1, arg2, arg3, arg4,
                arg5, arg6, arg7, arg8
        ...
        end     macro

You may not define nested macros. However, a macro can expand another macro expanding another macro and so on. The maximum supported nesting level of macro expansions is 65535.

To expand a macro name defined earlier in a source text and use arg1, arg2, … for the values of macro arguments, write a line like this:

        name    arg1, arg2, ...

The name of an expanded macro must be on a line of its own. The line must begin with either at least one whitespace character followed by that name or a location label definition followed by at least one whitespace character and that name.

The assembler preprocessor does not perform the substitutions of symbol names with symbol values in the names of expanded macros. However, the preprocessor performs such substitutions in the values of macro arguments. After substituting, the value of every macro argument must reduce to either a string literal or other text without string literals, spaces, and commas.

If you are expanding a macro using a long list of arguments, you can split the list into multiple lines. To indicate that a line of a list of arguments continues on the next line, terminate a continued line with a comma after the value of an argument. The following example demonstrates this:

        mac1    "alpha", 0.1, "beta",  0.2,
                "gamma", 0.3, "delta", 0.4

Next: , Previous: , Up: Using the Assembler Preprocessor   [Contents][Index]