Indexed and With Update

Started by Igglyboo, February 13, 2009, 03:13:41 AM

Previous topic - Next topic

Igglyboo

I've been trying to understand what these two meant when used in the context of some other op codes but i have no idea.
Could someone please elaborate?

i.e.
Store Word Indexed       stwx  rS, rA, rB
Store Word with update  stwu  rS, d(rA)

Link

This gateway to the world.. with a connection to the universe..

okay no.. there are pretty simple:

stwx  rS, rA, rB
-->
[rA+rB] = rS

stwu  rS, d(rA)
-->
[rA+d] = rS
rA = rA-4
(could be that I mix up the order - could also lower rA before, brkirch will probably know ^^)

Basically stwu is normally used on rA = r1 - r1 is the stack register, and thus you can store registers on the stack!

brkirch

Quote from: Link on February 13, 2009, 09:33:34 AMstwu  rS, d(rA)
-->
[rA+d] = rS
rA = rA-4
(could be that I mix up the order - could also lower rA before, brkirch will probably know ^^)
The register is changed after the value has been stored so that much is right, but actually it does not do rA = rA-4 but instead rA = rA+d.

Quote from: Link on February 13, 2009, 09:33:34 AMBasically stwu is normally used on rA = r1 - r1 is the stack register, and thus you can store registers on the stack!
To elaborate on that, the idea is that stwu will allow for the stack pointer to be stored AND changed with the same instruction.  If this was not possible then there would be a time between storing the stack pointer and changing it where the stack is corrupted; during that time an interrupt handler could try to use the stack and bad things could happen (crash, memory corruption, etc.).