III.10 Conditional Assembly

Conditional assembly allows to assemble or ignore selected parts of code. This can be used to keep the code for various program variants in a single source, to ease configuration control and maintenance. Conditional assembly is also useful to write fancy macros.
The following fourteen meta instructions have been implemented:

IF     <expr>            ELSEIF     <expr>
IFN    <expr>            ELSEIFN    <expr>
IFDEF  <symbol>          ELSEIFDEF  <symbol>
IFNDEF <symbol>          ELSEIFNDEF <symbol>
IFB    <literal>         ELSEIFB    <literal>
IFNB   <literal>         ELSEIFNB   <literal>
ENDIF                    ELSE

Meta instructions overlay the Intel MCS-51 assembly language, but are not part of it! C programmers may compare them to C preprocessor commands.
In the subsequent text, IFxx is used as a collective name for the IF/IFN/IFDEF/IFNDEF/IFB/IFNB instructions. In analogy ELSEIFxx is used as a collective name for the ELSEIF/ELSEIFN/ELSEIFDEF/ELSEIFNDEF/ELSEIFB/ELSEIFNB instructions (not including ELSE).

  1. General IFxx Construction
  2. IFxx and ELSEIFxx Instructions



[contents] [up] [back] [next]