SH: PC-relative addressing

Alexandre Oliva aoliva@redhat.com
Sun Sep 1 15:15:00 GMT 2002


On Aug 27, 2002, "Clarke, Stephen" <stephen.clarke@superh.com> wrote:

> I suspect that gas used to follow the Hitachi assembler
> behaviour, until it was changed as a result of the
> discussion beginning at:

> http://sources.redhat.com/ml/binutils/2002-01/msg00678.html

Actually, I don't think that patch ever changed the meaning of
@(number,pc), but rather only that of @(symbol-.,pc).  It had never
been disputed before that @(number,pc) should be adjusted by -4 before
encoding in the opcode, to reflect the fact that 4 had already been
added to PC by the time of the computation of the address.

I know, however, that some months later (in June 2002), Jörn posted
another patch
<URL:http://sources.redhat.com/ml/binutils/2002-06/msg00175.html> that
introduced code to accept some additional code from another SuperH
customer, introducing support for @(symbol,pc) as a synonym for
@symbol with PC-relative addressing, i.e., with `symbol-.-4' added to
`pc+4'.

In case we stop subtracting 4 from the PC addend in case of an
absolute number, should we also stop doing so in case of
@(symbol-.,pc)?  And how about in case of @(symbol,pc)?


As Jörn said, it is nice that @(num,pc) and @(symbol-.,pc) have the
same meaning, and that @(symbol-.,pc) actually refers to symbol's
memory address, instead of symbol+4.  However, I see that people more
familiar with the hardware addressing modes might be confused by the
offset implicitly adjusted by gas, and that those using the explicit
@(number,pc) instead of relying on the assembler to turn @symbol into
an equivalent expression should probably be using @symbol anyway, so
I'd be willing to accept a patch that made GNU as behave like the
Hitachi assembler.  However, it would be nice if such a patch
introduced a warning indicating a change in behavior.  It's likely
that this strikes so rarely that nobody will notice and be bothered
:-)

H-P, Jörn, do you concur?

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer



More information about the Binutils mailing list