Keil Logo

Conditional directives

5.15 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-5 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 version100068_0613_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.