Keil Logo

Conditional Assembly

The A166 Assembler supports conditional program assembly using several conditional assembly directives. Conditional assembly may be used to implement different program versions or different memory models within a single source file. Using conditional assembly, you can easily maintain one source module that satisfies several applications.

There are two distinct sets of conditional controls.

  • Conditional controls prefixed with the dollar-sign character ('$') are conditional directives. They can only test symbols that are defined using the $SET and $RESET directives.
  • Conditional controls with no preceding dollar-sign are conditional statements that may test a wider range of defined symbols. However, they may not test symbols that are defined with the $SET and $RESET directives.

The following assembler directives are provided for conditional assembly:

Directive Description
$IF Assemble block if condition is true.
$ELSE Assemble block if the condition of a previous $IF is false.
$ELSEIF Assemble block if condition is true and a previous $IF or $ELSEIF is false.
$ENDIF Ends a $IF block.
$SET Sets symbols, which may be tested by $IF or $ELSEIF, to true or a specified value.
$RESET Sets symbols, which may be tested by $IF or $ELSEIF, to false.
IF Assemble block if condition is true.
ELSE Assemble block if the condition of a previous IF is false.
ELSEIF Assemble block if condition is true and a previous IF or ELSEIF is false.
ENDIF Ends a IF block.

Note

  • Text blocks which are conditionally assembled must be enclosed by $IF, $ELSEIF, $ELSE, and $ENDIF or by IF, ELSEIF, ELSE, and ENDIF.
  • The $SET and $RESET directives may be used on the command-line to define symbols used in conditional directives.
  • Up to ten $IF or IF blocks may be nested. If a block is not translated, the nested conditional blocks, that are part of this block, are also skipped.
  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.