Shop OBEX P1 Docs P2 Docs Learn Events
P2 instruction question — Parallax Forums

P2 instruction question

Does the P2 have a similar instruction to JMPRET found in the P1?

I'm working on critical P1 code. While most P1 PASM commands work in P2 as well, I prefer using P2 for testing because it's significantly easier debugging features. This makes the coding process much smoother.

Comments

  • CALLD is the closest equivalent to what you'd normally use JMPRET for (jumping somewhere and writing the return address into a register). Of course the PC is longer than 9 bits on P2, so it overwrites the entire result register (on P1 you can patch the lower bits of another JMP(RET) instruction). Though for that hassle you get CZ in the MSBs in additon to the address (and using CALLD with WCZ will restore them from the source register).

  • RaymanRayman Posts: 13,860

    Gear might help with P1 PASM, in case you don't know about that...
    https://forums.parallax.com/discussion/156347/improved-gear-emulator/p1

  • Thank you for the responses: I will try out the CALL D instruction today.

    @Rayman - yes, I have gear and use it a lot (It was how to first learned how to use PASM)

  • evanhevanh Posts: 15,187
    edited 2024-03-22 13:58

    CALLD D,S is separate instruction from CALL D.

    From docs:
    CALLD D,S Call to S by writing {C, Z, 10'b0, PC[19:0]} to D.
    CALL D Call to D by pushing {C, Z, 10'b0, PC[19:0]} onto stack.

Sign In or Register to comment.