PowerPC assembler question

David Laight David.Laight at ACULAB.COM
Mon Jun 10 22:41:48 EST 2013


> > Note: It's more readable if you use the register names, ie:
> >
> > 	lwz	%r30, .label - (1b)(%r31)
> >
> > The form of lwz is
> >
> > 	lwz	dest_reg, offset(address_reg)
> >
> > So it will load a 32-bit value from memory at the address contained in
> > r31 offset by ".label - 1b" which is itself the difference between
> > two labels, "label", and the first "1:" label before the instruction
...
> Is there something I could replace this above lwz instruction with
> that would work for PIC with offsets greater than +/- 32k?

With a scratch register there are some two instruction sequences.
Reusing the destination register something like:
	addis	%r30,%r31,hi(.label - 1b)
	lwzx	%r30,lo(.label - 1b)(%r30)
(Not sure of the hi()/lo() functions for ppc!)
It is even possible that there are some macros for the
assembler that will do this automatically - %r1 might
even be reserved for the purpose (as it is on MIPS).

	David





More information about the Linuxppc-dev mailing list