Keil Logo

IF Assembler Directive

Abbreviation

None.

Arguments

IF expression

Default

None.

µVision

None.

Description

The IF directive begins an IF-ELSE-ENDIF construct that is used for conditional program assembly. The specified expression is evaluated and, if the value is non-zero (TRUE), the code inside the IF block is assembled. If the expression is zero (FALSE), the IF block is not assembled and subsequent blocks of the construct are evaluated.

IF blocks are terminated by an ELSEIF, ELSE, or ENDIF directive.

IF-ELSE-ENDIF blocks may be nested up to 10 deep.

Note

  • The specified expression may contain only those symbols defined using the SET and RESET directives. Symbols defined with the EQU and SET statements may not be used with the IF directive.
  • Do not confuse the IF directive with the IF statement. They are not equivalent and they may not be used with the same symbols.
  • This directive may not be specified on the command line. It must be specified in a source file.
See Also

ELSE, ELSEIF, ENDIF, RESET, SET

Example
$IF (SWITCH = 1)
.
.
.
$ELSEIF (SWITCH = 2)
.
.
.
$ELSE
.
.
.
$ENDIF
  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.