WORD COERSION

The unary operator (.word) is the word coersion operator. It instructs the XCASM compiler to use 16 bit quantities during computation of its operand (i.e the tagged part of the expression).

Consider the following example (where A, B and E are defined as byte variables) the expression:

	A = B + E
would generate
        0000    08 14           movf    B,w
        0001    07 19           addwf   E,w
        0002    00 93           movwf   A
Here you can see that the computation is carried out using 8 bit addition.

However if instead we used:

	A = (.word)(B + E)
this would generate
        0000    08 14           movf    B,w
        0001    01 83           clrf    wacc_1+1
        0002    07 19           addwf   E,w
        0003    18 03           btfsc   STATUS,C
        0004    0A 83           incf    wacc_1+1
        0005    00 93           movwf   A
Here you can see that the computation is carried out using 16 bit addition even though the quantities involved were only 8 bits. This is because we told the compiler to do so by using the (.word) operator.

To be exact, what the (.word) operator did was to tell the compiler that the sub-expression (B + E) should yield a 16 bit value, and the compiler produced code that would ensure that no information would be lost during the production of the 16 bit result. The subsequent assignment to the 8 bit variable A caused the most significant 8 bits of the 16 bit result to be discarded.