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:

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 12.1.12) 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 12.1.3) 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 12.2.8, follows:

            nam    conxampl
            ttl    ** Conditionals **

00000001        flag    set    1
00000001        flag2    set    1

005F0000        org    $5F0000

        * if flag=0, assemble to endc
00000001        ifeq    flag
        move D1,albert
        move fred,D1
        * if flag=1 assemble to endc
00000000        ifeq    flag-1
005F0000 33C1005F0012    move    D1,albert
005F0006 3239005F0016     move    morris,D1
        * Nested conditional
        * if flag2<=3, assemble
FFFFFFFE            ifle    flag2-3
005F000C 3239005F0014    move    fred,D1
        * if flag2=1, assemble
00000000            ifeq    flag2-1

        * trap flag2=1

**** WARNING at line 31    Fail directive encounted

005F0012 0000        albert    dc    0
005F0014 0000        fred    dc    0
005F0016 0000        morris    dc    0
24 bytes generated.