Skip to contentSkip to conversation

questions

DISCUSSION Kevin Diggs 2 participants 2 messages May 26, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

In idle_6xx.S one finds instructions like:

lis r4,powersave_nap@ha
lwz r4,powersave_nap@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?

Also, is there any performance difference between:

lbz rD,d(rA)
lhz rD,d(rA)
lwz rD,d(rA)

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

And is there any reason to prefer one over the other for doing byte
swapping:

lwbrx rD,rA,rB
stwbrx rS,rA,rB

kevin

#1 lore raw
Quoted 9 lines · Kevin Diggs

Hi,

In idle_6xx.S one finds instructions like:

lis r4,powersave_nap@ha
lwz r4,powersave_nap@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.

Quoted 5 lines

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.

Quoted 2 lines

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
[email protected]