beautypg.com

Zilog Z16F2810 User Manual

Page 162

background image

RET Instruction

UM018809-0611

146

ZNEO

®

CPU Core

User Manual

RET

Definition

Return

Syntax

RET

Operation

PC

 (SP)

SP

 SP

+

4

Description

This instruction returns from a procedure entered by a CALL instruction. The contents of the
location addressed by the Stack Pointer are loaded into the Program Counter. The next statement
executed is the one addressed by the new contents of the Program Counter. The Stack Pointer
also increments by four.

Any Push or other instructions in the subroutine that decrements the stack pointer must
be followed by matching Pop or increment instructions to ensure the Stack Pointer is at
the correct location when RET is executed. Otherwise, the wrong address loads into the
Program Counter and the program cannot operate properly.

Flags

Flags are not affected by this instruction.

Syntax and Opcodes

Example

Before:

PC=0035_292EH, SP=FFFF_DB1EH, FFFF_DB1CH=0000_0454H

RET

;Object Code: FFFC

After:

PC=0000_0454H, SP=FFFF_DB22H

Instruction, Operands

Word 0

Word 1

Word 2

RET

FFFCH

Caution:

This manual is related to the following products: