RTS returns to wrong place

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

RTS returns to wrong place

跳至解决方案
2,944 次查看
Vickyg
Contributor II
Hi,  I'm a newbie to assembler.  I've been tracing through my code trying to discover what is happening, and I've found that my RTS is returning to the wrong place.  Can anybody shed any light on a situation like this?
 
Thanks
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,338 次查看
Vickyg
Contributor II
Thank you both for your time and effort.  Just knowing that there were people out there on my side (me against the chip) was what I needed to get past my problem.  It turned out that I had changed chip sets and had missed that the add hx to a routines had moved and I was jumping in one point past where the stack pointer was incremented.  Stupid error on my part, but as a complete novice I was sure it was something like an overrun of the stack bounderies.
 
Thanks, your being there was very important to me.

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,338 次查看
kef
Specialist I
Is stack pointer (SP) pointing to RAM?
0 项奖励
回复
1,338 次查看
CompilerGuru
NXP Employee
NXP Employee
other things to check too
- stack is aligned, all the bytes added in the function have been removed before the RTS
- nothing in the function overwrites the return address
- the caller is using a JSR/BSR (and not CALL, for example)
- the stack is in RAM (as kef noted)
- the stack is allocated large enough.

Daniel
0 项奖励
回复
1,339 次查看
Vickyg
Contributor II
Thank you both for your time and effort.  Just knowing that there were people out there on my side (me against the chip) was what I needed to get past my problem.  It turned out that I had changed chip sets and had missed that the add hx to a routines had moved and I was jumping in one point past where the stack pointer was incremented.  Stupid error on my part, but as a complete novice I was sure it was something like an overrun of the stack bounderies.
 
Thanks, your being there was very important to me.
0 项奖励
回复