Return from Subroutine
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|
\(PC_l \longleftarrow (SP) \\ PC_h \longleftarrow (SP+1) \\ SP \longleftarrow SP+2\) | |||||||
RET | |||||||
1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 |
\(\begin{rcases} PC_l \longleftarrow (SP) \\ PC_h \longleftarrow (SP+1) \\ SP \longleftarrow SP+2 \end{rcases} \text{ if } ccc = true\) | |||||||
RET ccc | |||||||
1 | 1 | ccc | 0 | 0 | 0 |
ccc | Abbrev | Condition | Flag |
---|---|---|---|
000 | NZ | Non Zero | Z |
001 | Z | Zero | |
010 | NC | No Carry | C |
011 | C | Carry | |
100 | PO | Parity Odd | P/V |
101 | PE | Parity Even | |
110 | P | Sign Positive | S |
111 | M | Sign Negative |
Timing
The unconditional RET takes 10 (4,3,3) T-States. The conditional RET takes 17(5,3,3) T-States if the condition is true and 5 T-States if false and no return was performed.
Flags Affected
None. |
Opcode Matrix
Uncond | C | NC | Z | NZ | PE | PO | N | P | |
---|---|---|---|---|---|---|---|---|---|
RET |
RET
C9110 |
RET C
D8111 |
RET NC
D0111 |
RET Z
C8111 |
RET NZ
C0111 |
RET PE
E8111 |
RET PO
E0111 |
RET N
F8111 |
RET P
F0111 |
Instruction
Opcode hexSize bytesCycle count
| Flow |
Last modified November 16, 2021: Add flags to jp, jr, djnz & call operations (ae1613e)