Jump and Flow Control
Opcode | Action | Description |
---|---|---|
RET | fs-- | Will return back to the caller. This will POP the address from the stack. This will pop the value of R0 off the stack and jump to it. Note that trying to jump to an address outside of memory will not work, as the address is ANDed with |
RET Z | if Z = 1, RET | Will return back to the caller if the Z flag is set. If Z is clear, execution continues instead. |
RET NZ | if Z = 0, RET | Will return back to the caller if the Z flag is clear. If Z is set, execution continues instead. |
RET C | if C = 1, RET | Will return back to the caller if the C flag is set. If C is clear, execution continues instead. |
RET NC | if C = 0, RET | Will return back to the caller if the C flag is clear. If C is set, execution continues instead. |
JP nnnn | PC ← n*2 | This is unconditional and will jump every time. The Immediate value is shifted by 1 and will always be a even PC address. |
JP Z, nnnn | if Z = 1 | Will jump only if the Z flag is set. If Z is clear, execution continues instead. |
JP NZ, nnnn | if Z = 0 | Will jump only if the Z flag is clear. If Z is set, execution continues instead. |
JP C, nnnn | if C = 1 | Will jump only if the C flag is set. If C is clear, execution continues instead. |
JP NC, nnnn | if C = 0 | Will jump only if the C flag is clear. If C is set, execution continues instead. |
CALL nnnn | if Z = 1 | Jumps to a subroutine. The address of the NEXT instruction after CALL is pushed onto the stack, then the address of the CALL is jumped to. Execution then continues at the new address. An RET instruction can then be used to pop the saved address off the stack and return from the subroutine when the subroutine is finished. |
CALL Z, nnnn | if Z = 1 | Will call only if the Z flag is set. If Z is clear, execution continues instead. |
CALL NZ, nnnn | if Z = 0 | Will call only if the Z flag is clear. If Z is set, execution continues instead. |
CALL C, nnnn | if C = 1 | Will call only if the C flag is set. If C is clear, execution continues instead. |
CALL NC, nnnn | if C = 0 | Will call only if the C flag is clear. If C is set, execution continues instead. |