CONDITIONAL STATEMENTS

xif   expr   xthen   statement

The high level conditional if/then statement actually uses the reserved words xif/xthen. This is to remove ambiguity from the use of the xif, .if and .xcsim if statements.

Unlike the .if statement (which is used to conditionally exclude assembler source) or the .xcsim if statement (which is a simulation statement executated by the simulator and not the assembler), the xif statement is converted to the equivalent assembler code (by XCASM) which runs in the target CPU.

Example 1

	xif  a > b  xthen  goto lab_001
is equivalent to
                                ;;;-------------------
                                ;;;   xif   a > b 
                                ;;;   xthen goto lab_001 
                                ;;;-------------------

        0000    08 13                           movf    a,w

        0001    00 90                           movwf   xacc_1

        0002    08 14                           movf    b,w
        0003    02 10                           subwf   xacc_1,w

        0004    18 03                           btfsc   STATUS,C
        0005    28 07                           goto    xif_false_0

        0006                    xif_true_0
        0006    28 00                           goto    lab_001
        0007                    xif_false_0

Example 2

	xif  a > b  xthen  .let a = b
is equivalent to
                                ;;;-------------------
                                ;;;   xif   a > b 
                                ;;;   xthen .let a = b 
                                ;;;-------------------

        0000    08 13                           movf    a,w

        0001    00 90                           movwf   xacc_1

        0002    08 14                           movf    b,w
        0003    02 10                           subwf   xacc_1,w

        0004    18 03                           btfsc   STATUS,C
        0005    28 08                           goto    xif_false_0

        0006                    xif_true_0
                                ;;;   a = b 

        0006    08 14                           movf    b,w
        0007    00 93                           movwf   a
        0008                    xif_false_0

Example 3

	xif  a > b  xthen  bsf PORTA,1
is equivalent to
                                ;;;-------------------
                                ;;;   xif   a > b 
                                ;;;   xthen bsf PORTA , 1 
                                ;;;-------------------

        0000    08 13                           movf    a,w

        0001    00 90                           movwf   xacc_1

        0002    08 14                           movf    b,w
        0003    02 90                           subwf   xacc_1,w

        0004    18 03                           btfsc   STATUS,C
        0005    28 07                           goto    xif_false_0

        0006                    xif_true_0
        0006    14 85                           bsf     PORTA,1
        0007                    xif_false_0