6. Local Variables

Because Relogix has determined that the D0 and D1 registers (ECX and EAX in the x86 version) are not parameters to this function, it has created local variables to represent them (named i and token respectively). In addition, it has created a local variable to represent A0 (named p). At first sight this might be surprising. A0 corresponds to a parameter to the function; why is it also represented as a local variable?

When analyzing the use of registers in a function, Relogix looks at how they are used and changed. When a new value is placed in a register, it often means that the logical contents of the register are unrelated to the previous contents. In our example, A0 starts by being a pointer to a structure in memory. The instruction:

    MOVE.L    TOKBUF(A0),A0

creates a second, different, use for the register, as a pointer to an array of longs. Relogix therefore creates a different local variable for this use of the register.

Although most local variables in translated code correspond to registers in the original assembler, not all do. Relogix may also create local variables for data held on the stack, and also for conditions or specific flags in the condition-code register. Occasionally, as part of its translation, it may create further local variables for controlling the code-flow or as temporary values for translating certain instructions.