9.9 Macro directives

The .macro directive defines a new macro.


  .macro macro_name [, parameter_name]…
    // …



The name of the macro.


Inside the body of a macro, the parameters can be referred to by their name, prefixed with \. When the macro is instantiated, parameter references will be expanded to the value of the argument.

Parameters can be qualified in these ways:

Table 9-18 Macro parameter qualifier

Parameter qualifier Meaning
<name>:req This marks the parameter as required, it is an error to instantiate the macro with a blank value for this parameter.
<name>:varag This parameter consumes all remaining arguments in the instantiation. If used, this must be the last parameter.
<name>=<value> Sets the default value for the parameter. If the argument in the instantiation is not provided or left blank, then the default value will be used.


The .macro directive defines a new macro with name macro_name, and zero or more named parameters. The body of the macro extends to the matching .endm directive.

Once a macro is defined, it can be instantiated by using it like an instruction mnemonic:

macro_name argument[, argument]...

Inside a macro body, \@ expands to a counter value which is unique to each macro instantiation. This can be used to create unique label names, which will not interfere with other instantiations of the same macro.

The .exitm directive allows exiting a macro instantiation before reaching the end.


    // Macro for defining global variables, with the symbol binding, type and
    // size set appropriately. The 'value' parameter can be omitted, in which
    // case the variable gets an initial value of 0. It is an error to not
    // provide the 'name' argument.
    .macro global_int, name:req, value=0
    .global \name
    .type \name, %object
    .size \name, 4
    .word \value

    global_int foo
    global_int bar, 42
Non-ConfidentialPDF file icon PDF versionDUI0774J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.