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:
Directive | Condition |
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> |
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