5.12 Conditional directives

Conditional directives specify conditions that control whether or not to assemble a sequence of assembly code.

The following table shows how to translate armasm syntax conditional directives to GNU syntax directives:

Table 5-2 Conditional directive translation

armasm syntax directive GNU syntax directive
IF .if family of directives
IF :DEF: .ifdef
IF :LNOT::DEF: .ifndef
ELSE .else
ELSEIF .elseif
ENDIF .endif

In addition to the change in directives shown, the following syntax differences apply:

  • In armasm syntax, the conditional directives can use forward references. This is possible as armasm is a two-pass assembler. In GNU syntax, forward references are not supported, as the armclang integrated assembler only performs one pass over the main text.

    If a forward reference is used with the .ifdef directive, the condition will always fail implicitly. Similarly, if a forward reference is used with the .ifndef directive, the condition will always pass implicitly.

  • In armasm syntax, the maximum total nesting depth for directive structures such as IF...ELSE...ENDIF is 256. In GNU syntax, this limit is not applicable.
Non-ConfidentialPDF file icon PDF versionDUI0742J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.