PowerPC For Dummies: A simplified guide to understanding the PowerPC Instruction Set
#21
(06-28-2021, 10:44 PM)Vega Wrote: Yes.

Thanks!
Reply
#22
Hey, This isn't related to the last question but I'm wondering, is my understanding of these instructions correct?




lwzu


Load Word Zero Update
The value in Register A will be loaded into whatever Address is in Register B.
After the instruction is executed, The address in Register B is updated by the value you specify

 


EXAMPLE :
lwzu r1, 4(r2)

* The address in Register B starts as 0x80000004. After execution of this instruction, it becomes 0x80000008. It changed because it was updated by the pointer, which was 0x4. 


lwzx
Load Word Zero Indexed
The value in Register A will be loaded into whatever Address is in Register C.
After the instruction is executed, The address in Register C is updated by the value in Register A.
The new address is stored in Register B


 
EXAMPLE :
lwzx r1, r2, r3

*When I figure out how this works, I'll add an example
Reply
#23
lwzu looks good but lwzx is wrong, you could write them like this....

lwzu rA, VALUE (rB)

Register A is loaded with the word located at rB+VALUE. Afterwards, rB is incremented by the amount in VALUE.

--

lwzx rA, rB, rC

Register A is loaded with the word located at rB+rC.

--

Simple and straight to the point.
Reply
#24
(07-03-2021, 11:15 PM)Vega Wrote: lwzu looks good but lwzx is wrong, you could write them like this....

lwzu rA, VALUE (rB)

Register A is loaded with the word located at rB+VALUE. Afterwards, rB is incremented by the amount in VALUE.

--

lwzx rA, rB, rC

Register A is loaded with the word located at rB+rC.

--

Simple and straight to the point.


So whatever is the sum of register b and c added together becomes the pointer added to the address in register A? (for lwzx)
Reply
#25
It's called the Effective Address and that's how store and load instructions work.

Examples~

stw r0, VALUE (r3) #Effective Address aka EA (where store occurs) is VALUE+r3
lbz r5, VALUE (r10) #EA = VALUE+r10

These calculations are signed because all store and load instructions are signed. Meaning VALUE can be negative. If it is, do the sum accordingly.

Example~

lhzu r11, 0xFFFFFFFC (r9) #EA = -4 + r9, or easier to write it as r9 - 4 = EA.

Final Example (using lwxz)~

r5 = 0xFFFFFFF0 (aka -16 or -0x10)
r6 = 0x80001000

lwxz r4, r5, r6

EA = r5+r6 (0x80001000 minus 0x10)
Thus EA = 0x80000FF0

So the lwzx instruction will load the word located at 0x80000FF0 into r4.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)