Shop OBEX P1 Docs P2 Docs Learn Events
RETP going to wrong address — Parallax Forums

RETP going to wrong address

rcarmelrcarmel Posts: 13
edited 2006-06-14 04:03 in General Discussion
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

Comments

  • BeanBean Posts: 8,129
    edited 2006-06-13 22:58
    Richard,
    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
    ·
  • rcarmelrcarmel Posts: 13
    edited 2006-06-14 00:10
    Bean,

    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
  • BeanBean Posts: 8,129
    edited 2006-06-14 02:03
    Try adding "DEVICE STACKX, OPTIONX" without these the stack is only 2 levels deep. With these it is 8 levels deep.
    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
    ·
  • pjvpjv Posts: 1,903
    edited 2006-06-14 02:58
    Hi Bean;

    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)
  • rcarmelrcarmel Posts: 13
    edited 2006-06-14 04:03
    Yup, that did it.

    Thanks very much for your time and efforts.

    Richard
Sign In or Register to comment.