Crossware

Table of Contents        Previous topic       Next topic       

CROSS ASSEMBLER->Conditional Assembly

Conditional assembly allows code to be included or excluded from the assembly depending on particular conditions.  The IFcc and ENDC directives serve to define the statements to be conditional assembled.  If the operand to the particular IFcc directive satisfies the required condition, the statements up to the following ENDC will be assembled, otherwise they will be skipped.  The required condition depends on the particular IFcc directive as follows:
    
DirectiveCondition
    
IFEQ<Expression> =  0
IFNE<Expression> <> 0
IFGE<Expression> >= 0
IFGT<Expression> >  0
IFLE<Expression> <= 0
IFLT<Expression> <  0
IFC<Character string 1> = <Character string 2>
IFNC<Character string 1> <> <Character string 2>

Conditional assembly directives can be nested.

The UNA/NOUNA directives (described in section  ) control the listing of unassembled statements. Note that the unassembled statements, if they are listed, are not formatted.  If the UNA directive is not used only the ENDC command is listed (again unformatted).  

The CLIST/NOCLIST directives (described in section  ) control the listing of the IFcc and ENDC statements themselves.

An example which shows the use of conditional assembly, and also of the FAIL directive described later in section , follows:

   1                           nam     conxampl    
   2                           ttl     ** Conditionals **
   3                           list                
   4                           una                 
   5                           clist               
   6
   7 0001            flag      set     1           
   8 0001            flag2     set     1           
   9
  10 5F00                      org     $5F00       
  11
  12 0001                      ifeq      flag      if flag=0, assemble to endc
  13                      ldaa albert
  14                      staa fred
  15                 endc
  16
  17 0000                      ifeq    flag-1    if flag=1 assemble to endc
  18 5F00 B6 5F 09             ldaa    albert      
  19 5F03 B7 5F 0B             staa    morris      
  20                 *
  21                 * Nested conditional
  22                 *
  23 FFFE                      ifle    flag2-3   if flag2<=3, assemble
  24 5F06 B7 5F 0A             staa    fred        
  25 0000                      ifeq    flag2-1   if flag2=1, assemble
Warning at line 26      Fail directive encountered
  26                           fail                trap flag2=1
  27                           endc                
  28                           endc                
  29                           endc                
  30
  31 5F09            albert    rmb     1           
  32 5F0A            fred      rmb     1           
  33 5F0B            morris    rmb     1           
  34 5F0C                      end                 
Assembly complete
Bytes filed: 12
0 errors
1 warnings