With armasm, any number of custom macro parameters can be defined. Unspecified parameters are substituted with an empty string.

With the armclang integrated assembler, the custom macro parameters can optionally have a parameter type type. This can be either req or vararg. Unspecified parameters are substituted with an empty string.

The req type specifies a required parameter. The assembler generates an error when instantiating a macro if a required parameter is missing and a default value is not available.

The vararg type collects all remaining parameters as one parameter. It can only be used as the last parameter within the list of parameters for a given macro. Only one vararg parameter can be specified.

MEXIT directive

.exitm directive

Exit early from a macro definition.

IF,

ELSE,

ELIF,

ENDIF conditional assembly directives

.if family of directives,

and the .else,

.elseif,

.endif directives

The directives allow conditional assembly of instructions.

With armasm, the conditional assembly directives use a logical expression that evaluates to either TRUE or FALSE as their controlling expression.

With the armclang integrated assembler, multiple variants of the GNU assembly .if directive are available, referred to as the .if family of directives.

For the .if and .elseif directives, the controlling
expression is a logical expression that evaluates to either
TRUE or FALSE.

For other directives in the .if family of directives, the controlling expression is an implicit part of the directive used, and varies for each such directive.

WHILE,

WEND directives

.rept,

.endr directives

The directives allow a sequence of instructions or directives to be assembled repeatedly.

With armasm, the WHILE directive uses a logical expression that evaluates to either TRUE or FALSE as its controlling expression. The sequence enclosed between a WHILE and WEND directive pair is assembled until the logical expression evaluates to FALSE.

With the armclang integrated assembler, the GNU assembly .rept directive takes a fixed number of repetitions as a parameter. The sequence enclosed between a .rept and .endr directive pair is assembled the specified fixed number of times.

To replicate the effect of using a logical expression to repeatedly assemble a code sequence, the .rept directive can be used within a macro. See the example provided later in this section.

ASSERT directive

Use a combination of the .if family of directives and the .error directive.

With armasm, the ASSERT directive generates an error message during assembly if a given assertion is false. A logical expression that evaluates to TRUE or FALSE is used as the assertion.

With the armclang integrated assembler, this functionality can be achieved by using a GNU assembly directive from the .if family of directives to conditionally display an error message during assembly using the GNU assembly .error directive.

Macros can be created to simplify this process. See the example provided later in this section.

Notable differences between armasm macro syntax and GNU macro
syntax

The following syntax restrictions apply to GNU macro syntax in addition to the differences due to macro directives:

In armasm macro syntax, using the pipe character
| as the parameter value when
instantiating a macro selects the default value of the parameter. In GNU macro
syntax, leaving the parameter value empty when instantiating a macro selects the
default value of the parameter. If a default value is not specified in the macro
definition, an empty string is used.

In armasm macro syntax, a dot can be used between a
parameter and subsequent text, or another parameter, if a space is not required
in the expansion. In GNU macro syntax, a set of parentheses () can be used between a parameter and subsequent
text, if a space is not required in the expansion. There is no need to separate
a parameter from another subsequent parameter.

Although the integrated assembler is case-insensitive to register names, the GNU assembly .ifc directive always performs a case-sensitive comparison. Manually check that the register names use the same case-sense when comparing them using the directive.

The assembly-time variable for the loop counter. This parameter is required. The {$label} parameter for the MACRO directive has been used for this parameter. If a normal macro parameter is used, the parameter cannot be instantiated as a label.

$N

The maximum number of iterations for the loop. This parameter is required.

$decr

The loop decrement value. This parameter is optional.

do

The text to which $counter is appended in each iteration of the loop. This parameter is required.

Note:

The order in which the GNU assembly.ifgt, .endif, .rept, and .endr directives are used is important. Including the .endr directive as a statement within the .ifgt ... .endif structure produces an error. Similarly, placing the .endif directive outside the .rept ... .endr structure produces an error.

The macro expansion produces the following code:

mov r0, #0xa
mov r0, #8
mov r0, #6
mov r0, #4
mov r0, #2

Notable differences from the armasm syntax
implementation:

In the armasm syntax implementation, the ASSERT directive is used to
raise an error if a required parameter is missing. In the
GNU syntax implementation, this can be achieved by using the
parameter type req for
required parameters in the macro definition.

In the armasm syntax implementation, the macro
instantiation uses a string as the value to the $do parameter. The quotes are
implicitly removed at assembly-time. Quotes are required as
the parameter value contains spaces. In the GNU syntax
implementation, this is achieved using the parameter type
vararg for the \do parameter in the macro
definition.

In the GNU syntax implementation, the .rept
... .endr structure is always evaluated \N times at assembly-time.
This is because the .ifgt ...
.endif structure must be placed within the
.rept ... .endr
structure. In the armasm syntax
implementation, the WHILE...WEND structure is only evaluated the
required number of times at assembly-time based on the
controlling expression of the WHILE directive.