RETP going to wrong address
rcarmel
Posts: 13
I have some code running on a SX28.· At the end of one of my subroutines, the RETP sets the program counter to the wrong place.· This only seems to happen when that subroutine, calls a second sub routine.· So to clarify I have:
Main
Call @DrawLine
org SOME_ROM_PAGE
DrawPixel
<some code here>
RETP
org SOME_OTHER_ROM_PAGE
DrawLine
<some code here>
Call @DrawPixel
RETP
I would expect the code to call the drawline, then the drawpixel, then return to the drawline, then to the main...· But instead, the last RETP puts the instruction counter somewhere in the middle of the DrawLine routine.· I'm sure this is something to do with Page boundaries, and the strange memory mapping of the SX, but haven't been able to figure it out.
Any input appreciated
Richard Carmel
Main
Call @DrawLine
org SOME_ROM_PAGE
DrawPixel
<some code here>
RETP
org SOME_OTHER_ROM_PAGE
DrawLine
<some code here>
Call @DrawPixel
RETP
I would expect the code to call the drawline, then the drawpixel, then return to the drawline, then to the main...· But instead, the last RETP puts the instruction counter somewhere in the middle of the DrawLine routine.· I'm sure this is something to do with Page boundaries, and the strange memory mapping of the SX, but haven't been able to figure it out.
Any input appreciated
Richard Carmel
Comments
You will have to post the COMPLETE code for us to help you.
From what you have posted, it looks like it should work as you expect.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"I reject your reality, and substitute my own." Mythbusters
·
Thanks for your reply.· I guess I was just hoping for some "look out for this...", "don't forget about..." type responses that might point me to some common mistakes made.· But I suppose this isn't practical.· I will post the code when I get home.
Rich
Let me know if that fixes it...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"I reject your reality, and substitute my own." Mythbusters
·
Nice find !!!!
It's not my code, but far as my debugging sees, that fixes it.
I was wracking my brain as to why the call stack was being over-run. Sooo simple..... ARGGGG.
Cheers,
Peter (pjv)
Thanks very much for your time and efforts.
Richard