e_stwu/stwu problem

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

e_stwu/stwu problem

Jump to solution
2,908 Views
Routh
Contributor I

Hi,

I have problem about stack on my 5604b system.

I want to create a section of stack frame, the size of which is 0xA8 byte.

the code like this:

e_stwu r1, -0xA8 (r1)

but the result is r1=r1-0x58 , I don't know what happened.How can I reliaze this purpose?

Very grateful for your assistance

1 Solution
1,849 Views
TomE
Specialist II

You need to read up on the instruction you're trying to use.

 

Documented in "Variable-Length Encoding (VLE) Programming Environments Manual," as:

 

    e_stwu rS,D8(rA)

 

There are only 8 SIGNED bits available in the VLE version for the offset, so you're limited to -0x80 to 0x7f (0x70 or 0x7c for alignment).

 

Initially I thoughy you could code it as:

 

e_stwu r1, -0x70 (r1)

e_stwu r1, -0x38 (r1)

 

BUT that would end up with the wrong value stored on the stack, breaking the stack linkage, so it needs something a little smarter than that involving another temporary register.

 

I'd suggest you write a small C function with more than 0x80 bytes of function-local variables/storage, compile it and then disassemble it to see how the compiler solved this problem. Then copy what it did into your assembly code.

 

Tom

View solution in original post

3 Replies
1,850 Views
TomE
Specialist II

You need to read up on the instruction you're trying to use.

 

Documented in "Variable-Length Encoding (VLE) Programming Environments Manual," as:

 

    e_stwu rS,D8(rA)

 

There are only 8 SIGNED bits available in the VLE version for the offset, so you're limited to -0x80 to 0x7f (0x70 or 0x7c for alignment).

 

Initially I thoughy you could code it as:

 

e_stwu r1, -0x70 (r1)

e_stwu r1, -0x38 (r1)

 

BUT that would end up with the wrong value stored on the stack, breaking the stack linkage, so it needs something a little smarter than that involving another temporary register.

 

I'd suggest you write a small C function with more than 0x80 bytes of function-local variables/storage, compile it and then disassemble it to see how the compiler solved this problem. Then copy what it did into your assembly code.

 

Tom

1,849 Views
Bloodhound
Contributor I

Would have been great to see the code produced because I have run in to the same problem with the command

e_stwu  

r1,-0x84(r1)

0 Kudos
Reply
1,849 Views
pradeepmc
Contributor II

Posting the reply even though it is late. Since it may help other people. 

We can use the below when the offset is more the 0x7f. 

e_stw r1, -0x84(r1)

e_add16i r1,r1, -0x84

0 Kudos
Reply