Port-powerpc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: COMPAT_LINUX: assembly level tricks (long)



>>>>> Emmanuel Dreyfus writes:

Emmanuel> About syntax problems: I'm not sure of the following:
Emmanuel> by "lwz r11,(target)" I mean put in r11 the value contained at the
Emmanuel> address of "target:". Is it right?
Emmanuel> and by jmp r11, I mean jump inconditonnaly to address contained in 
r11.
Emmanuel> I'm not sure of the mnemonic. 

        PowerPC is not a VAX. :^)

        lwz rD,d(rA)

loads the word at register rA plus displacement d into register rD.  lwz
is one of the instructions which treats rA=0 as 0, i.e., load value at 0+d
regardless of the value of r0.  The displacement is limited to 16 bits.
One cannot place an arbitrary address and expect the assembler to fix it
up. 

        This type of code already is written in locore.S for PowerPC,
e.g., arch/macppc/macppc/locore.S, so I suggest that you use that as a
template.

        Also, one only may branch to an address in the link register (LR)
or count register (CTR).

        lis     r9,_C_LABEL(target)@ha
        lwz     r8,_C_LABEL(target)@l(r9)
        mtctr   r8
        bctr

Hint: if one is not going to return to the address, better to branch via
the CTR than the LR so that the link register stack is not invalidated.

Emmanuel> I'm also looking for a PowerPC assembly language reference, I don't 
have
Emmanuel> very good documentation.

        The Motorola and IBM websites have the PowerPC instruction sets
online as PDF files.

http://www.mot.com/SPS/PowerPC/teksupport/teklibrary/index.html

David



Home | Main Index | Thread Index | Old Index