Mnemonics

CALL

Call and Return Group
Expansion:
CALL
Usage:
call [f,]{address}

The call instruction saves the current Program Counter (PC) value on the stack and then jumps to the address of the subroutine. The return (RET) instruction is used at the end of the subroutine, which pops the saved PC value from the stack and jumps back to that location.

Note that JP provides a similar operation in that it changes the flow of execution, except jp does not use a return address while CALL will include this on the stack.

Z80.CPU instructions
Instruction Description Opcode
CALL {address} No condition CD {????}
CALL Z, {address} Zero flag (Z) is set CC {????}
CALL NZ, {address} Zero flag (Z) is not set C4 {????}
CALL C, {address} Carry flag (C) is set DC {????}
CALL NC, {address} Carry flag (C) is not set D4 {????}
CALL M, {address} Minus flag (S) is set (minus sign) EC {????}
CALL P, {address} Plus flag (S) is not set (plus sign) E4 {????}
CALL PO, {address} Parity odd or has overflow flag (P) is set FC {????}
CALL PE, {address} Parity even or had no overflow flag (P) is not set F4 {????}

Example 1

call $9876 ; Call the subroutine at address $9876 ; ... ; Address $9876 ; ... (subroutine code) ret ; Return from the subroutine

Example 2

call myLabel ; Call the subroutine at myLabel ; ... myLabel: ; ... (subroutine code) ret ; Return from the subroutine

Example 3

call c, myCond ; Call the subroutine at myCond if Carry flag (C) is set ; ... myCond: ; ... (subroutine code) ret ; Return from the subroutine

See also