PowerPC - sth and sthu opcodes

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PowerPC - sth and sthu opcodes

1,041 Views
Bloodhound
Contributor I

Hi All,

 

I'm just trying to get a clear understanding of the store and store with update commands, the store with update don't seem to be working for me as I thought they would.

When I store a byte, word or long word with the store and update command shouldn't the register that contains the store address then automatically increase by the size of the data stored?

 

Eg....lets assume I set up an address in r9 as 0x60010000

sthu  r5,0(r9) = Store word in r5 to 0x60010000, and automatically increment (update) r9 by 2 as we stored a word (so r9 now = 0x60010002)

stbu  r5,0(r9) = Store byte in r5 to 0x60010000, and automatically increment (update) r9 by 1 as we stored a byte (so r9 now = 0x60010003)

 

Is that correct on how those commands works?

 

Currently I am manually adding to the address in r9 after a stb or sth like so:

sth  r5,0(r9) = Store word in r5 to 0x60010000

addi  r9,r9,2 = increment (update) r9 address by 2 as we stored a word (so r9 = 0x60010002)

 

Obviously that isn't very efficient if I need to store multiple things.

 

Thanks.

Labels (1)
0 Kudos
2 Replies

809 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

here is the description of sthu instruction:

It says that "EA is placed to rA". And the EA is rA + D.

So, if you use "sthu r5,0(r9)" where r9=0x60010000 then the r9 will remain the same because rA+D is still 0x60010000.

If you use "sthu r5,2(r9)" then r9 will be 0x60010002.

Lukas

0 Kudos

809 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

It seems the picture was removed - you will find it attached.

0 Kudos