Coding Questions and other Quandaries
#31
I have come across this command a few times and it plays a part in a code for a GCN game I'm revisiting.
Perhaps you can shed some light on parts of it I don't understand.
Would be nice if they actually put an example in the programming guide.

rlwinm
rlwinm.


Rotate Left Word
Immediate then
AND with Mask


rA,rS,SH,MB,ME

The contents of register rS are rotated left by the number of bits specified
by operand SH (this much I understand).

A mask is generated having 1 bits from the bit specified
by operand MB + 32 through the bit specified by operand ME + 32 and 0
bits elsewhere. The rotated data is ANDed with the generated mask and
the result is placed into register rA.

rlwinm Rotate Left Word Immediate then AND with Mask
rlwinm. Rotate Left Word Immediate then AND with Mask with CR
Update. The dot suffix enables the update of the CR.

Here's actual code from the game I'm working on with value specified in pertinent register:

lhz r3, 0x28 (r31) #ASM Loads 0xD08 into r3
li r0, 1
ori r3,r3, 0x4 #ASM r3= 0xD0C
sth r3, 0x28 (r31)
lhz r3, 0x28 (r31) #ASM Not sure why they did this. Seems like unneeded code.
rlwinm r3, r3, 0, 16, 30 (0000FFFE) #ASM r3 = 0xD0C. What was the point? How is (0000FFFE) generated with 16, 30? That's where the lose me.
sth r3, 0x28 (r31)

Thanks for your help!!!!
Reply


Messages In This Thread
RE: Coding Questions and other Quandaries - by Hackwiz - 12-13-2021, 12:02 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)