10. Simplification


As it translates code, Relogix is often able to combine several assembler instructions into one C statement or expression. In our example, the lines:


    BEQ.S    DONE
    TST.L    TOKBUF(A0)
    BEQ.S    DONE

have been combined into a single if clause:



if (i != 0 && tok_ptr->tokbuf != NULL)


This simplification of the code may sometimes result in the elimination of local variables. For example, in a routine like this:


MUL10:
    MOVEM.L    D1/D2,-(A7)
    MOVE.L     D1,D2 
    LSL.L      #3,D1
    LSL.L      #1,D2
    ADD.L      D2,D1
    MOVE.L     D1,(A0)
    MOVEM.L    (A7)+,D1/D2
    RTS

D2 represents a temporary local variable which Relogix will be able to eliminate. The final translation is greatly simplified:



void mul10 (long val, long *ptr)
{
    *ptr = val * 10;  
}