/opcodes/ret

Control Flow // RET (RETurn)

Description

The byte at the memory location specified by the contents of the Stack Pointer (SP) Register pair is moved to the low-order eight bits of the Program Counter (PC). The SP is now incremented and the byte at the memory location specified by the new contents of this instruction is fetched from the memory location specified by the PC. This instruction is normally used to return to the main line program at the completion of a routine entered by a CALL instruction.

Example

The Program Counter contains 3535h, the Stack Pointer contains 2000h, memory location 2000h contains B5h, and memory location 2001h contains 18h. Upon the execution of a RET instruction, the Stack Pointer contains 2002h and the Program Counter contains 18B5h, thereby pointing to the address of the next program op code to be fetched.

Opcodes