Brad Boyer flar at
Mon May 26 07:31:25 EST 2008

On Sun, May 25, 2008 at 05:32:29PM -0700, Kevin Diggs wrote:
> Hi,
> 	In idle_6xx.S one finds instructions like:
> 	lis   r4,powersave_nap at ha
> 	lwz   r4,powersave_nap at l(r4)
> Can someone explain what this is doing? Presumably the first is loading 
> an address and the second a value. What do the '@ha' and '@l' do?

The @ha and @l are modifiers to turn a 32 bit constant into a 16 bit
constant that would be useful in particular contexts. The @l takes
the low halfword, while the @ha takes the high halfword and modifies
it so that if you add in the low halfword you get the full 32 bit
value. There are other modifiers for other uses. You need these in
ppc assembly because there isn't any way to directly use a 32 bit
immediate value. In this particular case, it's taking advantage of
the indirect addressing modes to load a word from a constant 32 bit
address. It loads the high halfword of the pointer into r4 with the
lis instruction, then the low halfword is added during the effective
address calculation. The value at that constant address is loaded
into r4. Normally a 32 bit constant gets loaded with lis and addi,
but this is a way to avoid the extra instruction because it intends
to use the result as a pointer. The indirect addressing gives you
a free addi as long as you don't need to save the result.

> 	Also, is there any performance difference between:
> 	lbz rD,d(rA)
> 	lhz rD,d(rA)
> 	lwz rD,d(rA)

Normally you would use the one you need. I'd be surprised if there was
any difference in performance, but I also can't think of any reason
you would choose one over another for performance reasons even if there
was a difference.

> 	While I'm wasting your time, I picked up an ADB infrared wireless 
> keyboard. I think it works. But not under Linux. Should it?

If it acts like a normal ADB keyboard, it should work. Does it need a
special driver with the MacOS? If so, then it would probably need a
custom driver in Linux as well.

	Brad Boyer
	flar at

More information about the Linuxppc-dev mailing list