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 $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