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     5F00H       
  11
  12 0001                      ifeq    flag        ;if flag=0, assemble to endc
  13                     mov    dptr,#albert
  14                     movx    a,@dptr
  15                     mov    dptr,#fred
  16                     movx    @dptr,a
  17                 endc
  18
  19 0000                      ifeq    flag-1      ;if flag=1 assemble to endc
  20 5F00 90 5F 0C             mov     dptr,#albert
  21 5F03 E0                   movx    a,@dptr     
  22 5F04 90 5F 0E             mov     dptr,#morris
  23 5F07 F0                   movx    @dptr,a     
  24
  25                 ;
  26                 ; Nested conditional
  27                 ;
  28 FFFE                      ifle    flag2-3     ;if flag2<=3, assemble
  29 5F08 90 5F 0D             mov     dptr,#fred  
  30 5F0B F0                   movx    @dptr,a     
  31 0000                      ifeq    flag2-1     ;if flag2=1,assemble

conxampl.asm: **** WARNING at line 32      Fail directive encounted
  32                           fail                ;trap flag2=1
  33                           endc    
  34                           endc    
  35                           endc    
  36
  37 5F0C            albert    ds      1           
  38 5F0D            fred      ds      1           
  39 5F0E            morris    ds      1           
  40                           end     
Assembly complete
Total bytes generated: 15
0 errors
1 warnings