Shop OBEX P1 Docs P2 Docs Learn Events
Call/return mechanism — Parallax Forums

Call/return mechanism

mahjonggmahjongg Posts: 141
edited 2007-02-04 22:55 in Propeller 1
I understand that the cog's do not have a return stack mechanism.

But do I understand correctly that a Call instruction not only does a jump to the subroutine, but also, at run time, modifies the correct return instruction so that return instruction will jump back to the right place (directly after the originating call)?
I't the only thing that makes sense, and the manual is a bit scarce on the actual details.

Mahjongg

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-04 22:55
    Yes, the JMPRET instruction stores the address of the next instruction into the source field of the destination, then jumps to the address in the source field of the JMPRET. The CALL instruction is a kind of macro that produces a JMPRET by taking the label of the jump address and adding a "_ret" to it and checking that the actual resulting line contains a RET instruction (which itself is really a JMP instruction).
Sign In or Register to comment.