RTS returns to wrong place

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

RTS returns to wrong place

Jump to solution
2,174 Views
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
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
568 Views
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.

View solution in original post

0 Kudos
Reply
3 Replies
568 Views
kef
Specialist I
Is stack pointer (SP) pointing to RAM?
0 Kudos
Reply
568 Views
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 Kudos
Reply
569 Views
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 Kudos
Reply