Ax51 User's Guide

Conditional Assembly

The Ax51 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:

DirectiveDescription
$IFAssemble block if condition is true.
$ELSEAssemble block if the condition of a previous $IF is false.
$ELSEIFAssemble block if condition is true and a previous $IF or $ELSEIF is false.
$ENDIFEnds a $IF block.
$SETSets symbols, which may be tested by $IF or $ELSEIF, to true or a specified value.
$RESETSets symbols, which may be tested by $IF or $ELSEIF, to false.
IFAssemble block if condition is true.
ELSEAssemble block if the condition of a previous IF is false.
ELSEIFAssemble block if condition is true and a previous IF or ELSEIF is false.
ENDIFEnds 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.