ELSE - Conditional assembly

Syntax
IF <condition> 
  [<assembly language statements>]
[ELSE] 
  [<assembly language statements>] 
ENDIF 
Synonym
ELSEC 
Description

If <condition> is true, the statements between IF and the corresponding ELSE directive are assembled (generate code).

If <condition> is false, the statements between ELSE and the corresponding ENDIF directive are assembled. Nesting of conditional blocks is allowed. The maximum level of nesting is limited by the available memory at assembly time.

Example

The following listing is an example of the use of conditional assembly directives:

Listing: Various conditional assembly directives

Try: EQU     1
     IF Try  != 0

       LDA   #103

     ELSE

       LDA   #0

     ENDIF

The value of Try determines the instruction to be assembled in the program. As shown, the lda #103 instruction is assembled. Changing the operand of the EQU directive to 0 causes the lda #0 instruction to be assembled instead.

Listing: Output listing


 Abs.  Rel.     Loc    Obj. code   Source line
---- ----   ------ ---------   ------------------

    1    1          0000 0001   Try: EQU   1

    2    2          0000 0001        IF  Try != 0

    3    3   000000 A667               LDA   #103

    4    4                           ELSE

    6    6                           ENDIF