e_stwu/stwu problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

e_stwu/stwu problem

跳至解决方案
3,742 次查看
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 解答
2,683 次查看
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

在原帖中查看解决方案

3 回复数
2,684 次查看
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

2,683 次查看
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 项奖励
回复
2,683 次查看
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 项奖励
回复