Mnemonics

RET

Call and Return Group
Expansion:
RETurn
Usage:
ret [r]

Both conditional and unconditional types of return exist. In either case the return address is taken from the top of the stack and is used in the (PC) Program Counter registry.

Z80.CPU instructions
Instruction Description Opcode
RET No comparision, just return C9
RET C If (C)arry flag is set, then return D8
RET NC If (C)arry flag is not set, then return D0
RET Z If (Z)ero flag is set, then return C8
RET NZ If (Z)ero flag is not set, then return C0
RET PE If (P)arity flag is set (Parity Even), then return E8
RET PO If (P)arity flag is not set (Parity Odd), then return E0
RET M If (S)ign flag set (Minus, aka a negative number), then return F8
RET P If (S)ign flag is not set (Positive, aka a positive number), then return F0

Example unconditional return

call mySubroutine ; some code here mySubroutine: ; subroutine code here ret ; return unconditionally to the instruction following the CALL

Example conditional return

call checkValue ; some code here checkValue: cp 10 ; compare A with 10 ret z ; return if A is equal to 10 ; code here will execute if A is not 10 ret ; unconditional return if A is not 10

See also