On 12 September 2010 17:53, Justin R. Bendich <[email protected]> wrote:
> LA    R1,256           <- Line 1
>         USING 256,R1           <- Line 2
>         LA    R3,512(R2)       <- Line 3
>
> The thread has been that, because of line 2, the assembler will
> generate line 3 as follows:
>
>   4132 1100            LA    R3,512(R2)
>
> If what i really want is for R3 to contain R2 + 512

That's exactly what the generated instruction will produce. How does
it not meet your requirement?

The USING and DROP assembler directives are very useful, but the
cardinal rule is "don't lie to the assembler". If you tell it, by
means of a particular USING instruction at assembly time, that a
certain value will be in a certain register at run time, the assembler
feels it reasonable to trust you, and will generate code that relies
on your having set up that register as advertised. If you fail to do
that, the code is likely to not produce the result you expect.

I believe in this case the assembler generates the instruction this
way because it is following the rule of using the register that will
produce the smallest displacement in the instruction. Typically there
is no register other than R0 (with its implied content of 0) available
this use, but your USING on R1 allows a smaller displacement to be
generated.

Tony H.

Reply via email to