On Thu, 9 Sep 2010 00:32:37 -0600, Paul Gilmartin wrote:

>Which has the more obvious meaning:
>
>          LA    R3,-4(R2)       Set R3 to 4 less than R2
>
>or:
>
>          LA    R3,4092(R1,R2)  Set R3 to 4 less than R2
>
>?  The first hardly needs the comment to show the programmer's
>intention, and the assembler's checking of addressability
>window makes it less error prone.

It is not clear to me that the first is less error prone, especially
when the program is modified later.  Either of these eats up another
register to be used as an index.  Unless the value of register 1 is
set in close proximity to the LA, I would find the code to be
confusing.  And if it is set immediately before the LA, you could
also code:

          LHI   R1,-4
          LA    R3,0(R1,R2)

A better solution (IMO) is:

          LR    R3,R2
          AHI   R3,-4

--
Tom Marchant

Reply via email to