Table of Contents        Previous topic       Next topic       

ASSEMBLER DIRECTIVES->Other Assembler Directives->IFC IFNC IFIC IFINC Conditional Assembly with String Comparison

These directives cause the assembly of the subsequent block of statements to be dependant upon the comparison of two character strings in the operand.  The ENDC directive marks the end of the statement block.  


IFC<string 1>,<string 2><comment>
IFNC<string 1>,<string 2><comment>
IFIC<string 1>,<string 2><comment>
IFINC<string 1>,<string 2><comment>

The statements following IFC and IFIC will be assembled if string 1 and string 2 are the same.  The statements following IFNC and IFINC will be assembled if string 1 and string 2 are different.  IFC and IFNC perform a case sensitive comparison on the two strings whereas IFIC and IFINC perform a case insensitive comparison.  

These directives are usually used in macro definitions where either one or both of the strings is a macro argument.  The directives can then be used to generate different object code depending on the string or strings passed in the argument or arguments.  These conditional assembly directives can be nested.

The following example shows the use of the string comparison conditional assembly directives:

    1            nam    ifcnc
    2            ttl    *** IFC and IFNC ***
    3            opt    mc,mex,md  
    5            sam   macr
    7            ifc \0,disc
    8            ifnc \1,check
    9            fail
    10        endc
    11            dc.b 'disc'
    12            dc $1234
    13        endc
    15            ifc \0,ram
    16            dc.b 'ram'
    17            even
    18            dc.w $5678
    19        endc
    21            endm
    23            *** Show macro expansions
    25            sam    disc,check
                ifc    disc,disc  
                ifnc    check,check
    00000000 64697363    dc.b    'disc'
    00000004 1234        dc    $1234
                ifc    disc,ram    
    27            sam    disc
                ifc    disc,disc  
                ifnc    ,check     

Warning at line 27        Fail directive encountered
    00000006 64697363    dc.b    'disc'
    0000000A 1234        dc    $1234
                ifc    disc,ram    
    29            sam    ram
                ifc    ram,disc
                ifnc \1,check
                ifc    ram,ram
    0000000C 72616D    dc.b    'ram'
    0000000F 00            even
    00000010 5678            dc.w    $5678
    31        end    
Assembly complete
Bytes filed: 18
0 errors
1 warnings