PowerPC For Dummies: A simplified guide to understanding the PowerPC Instruction Set
(06-27-2021, 10:23 PM)JimmyKazakhstan Wrote: Thanks for taking the time to answer all of these btw. Most people would've gotten annoyed by the amount of questions I ask.

No worries at all. I like teaching people this stuff as long as they are truly willing to learn and put in the work

The first bit of a value is its most significant bit. It's also known as bit 0. Some PPC manuals may refer to bit 0 as the 'sign' bit as that is the bit alone that determines whether or not a value is negative as long as that particular instruction treats its values as signed to begin with.

i.e. 0x80000000 = negative, bit 0 (sign bit) has the value of 1. Binary value of 1000 makes the hex digit 8.

The final bit of a value is the least significant bit. Also known as bit 31.


2. Update and Indexed is simply the combination of both.

Let's break down a simple stwx instruction first

stwx r3, r4, r5

r3 = 0x00000001
r4 = 0x00002000
r5 = 0x80000000

Instead of having a 16-bit Immediate VALUE being used to calculate the address of where the store will be done at in memory (VALUE + Source Register), that calculation is done with two source registers being added together.

r4 + r5 = 0x80002000 #This is the address in memory where the word value of r3 (0x00000001) will be stored at after the instruction has executed.

Now let's break down a stwu instruction, just as a refresher
stwu r3, 0x2000 (r5)

Using same values for r3 and r5 as before, for the first time this instruction is executed 0x2000 is added to r5 to calculate the address where r3's word value is stored to, so it stores to 0x80002000. However after that store occurs, r5 gets incremented by 0x2000 to 0x80002000. If you execute the instruction a 2nd time you are now adding 0x2000 to 0x80002000 so r3's word will store at 0x80004000. Every time you execute this instruction r5 keeps increasing by 0x2000.

Ok now finally going to a stwux instruction
stwux r3, r4, r5

r3 = 0x00000001
r4 = 0x80000000
r5 = 0x00002000

In any update+indexed storing/loading instruction; the register that gets incremented with the new value is the 1st source register (the middle register, NOT the far right register)

Anyway, first time this instruction executes, take r4 +r5, so r3's word stores at 0x80002000. Then r4's value gets incremented by r5's value. So if you execute this instruction a 2nd time, r4 is now 0x80002000 when you add it with r5, you get 0x80004000. Thus r3's word value now stores at 0x80004000. r4's value keeps incrementing by r5's value every time the instruction gets executed

The only reason you would need a stwux/lwux type instruction is the amount you wanna keep increasing exceeds the 16-bit signed limit (0xFFFF8000 thru 0x7FFF)


Google something like "pokeacer Broadway Manual" and you will be able to find the actual Broadway manual, I can't host it on this site for obvious reasons


That's just one clever usage for OR'ing. There's many other purposes for OR.


Just be careful using examples of r0, because of the literal 0 rule in certain instructions. Stick to r3 thru r12; r14 thru r31 for example purposes. r1 is the sp (stack pointer), r2 is rtoc (register table of contents) and r13 is used as a global type of pointer which should never be modified that points to a small region of important data.

Messages In This Thread
RE: PowerPC For Dummies: A simplified guide to understanding the PowerPC Instruction Set - by Vega - 06-27-2021, 11:17 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)