RET
Instruction: Return to previously recorded address.
RET
Opcode Table:
–INSTR– ZCRI –CON– –DEST– –SRC– | Z Result | C Result | Result | Clocks |
010111 0001 1111 --------- --------- | Result = 0 | — | Not Written | 4 |
Concise Truth Table:
In | Out | ||||||
Destination1 | Source | Z | C | Effects | Destination2 | Z | C3 |
$----_----; - | $----_----; - | - | - | wr wz wc | 31:9 unchanged, 8:0 = PC+1 | 0 | 1 |
1 Destination is normally ignored for RET usage, however if the WR effect is given, the RET instruction becomes a CALL instruction and Destination's s-field (lowest 9 bits) are overwritten with the return address (PC+1).
2 Destination is not written unless the WR effect is given.
3 The C flag is set (1) unless PC+1 equals 0; very unlikely since it would require the RET to be executed from the top of cog RAM ($1FF; special purpose register VSCL).
Explanation
RET returns execution to a previously recorded address by setting the Program Counter (PC) to that address. The RET instruction is meant to be used along with a label in the form "label_ret" and a CALL instruction that targets RET's routine, denoted by "label." See CALL for more information.
RET is a subset of the JMP instruction but with the i-field set and the s-field unspecified. It is also closely related to the CALL and JMPRET commands; in fact, they are all the same opcode but with different r field and i-field values and varying assembler-driven and user-driven d field and s field values.
Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.