Datasheet
Item n
PC
Return
Item n
Stack before RET
instruction
Stack after RET
instruction
SP
SP
www.ti.com
Instruction Set Description
4.6.2.36 RET
RET Return from subroutine
RET
Syntax
Operation @SP →PC.15:0 Saved PC to PC.15:0. PC.19:16 ← 0
SP + 2 → SP
Description The 16-bit return address (lower 64KB), pushed onto the stack by a CALL instruction is
restored to the PC. The program continues at the address following the subroutine call.
The four MSBs of the PC.19:16 are cleared.
Status Bits Status bits are not affected.
PC.19:16: Cleared
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Call a subroutine SUBR in the lower 64KB and return to the address in the lower 64KB
after the CALL.
CALL #SUBR ; Call subroutine starting at SUBR
... ; Return by RET to here
SUBR PUSH R14 ; Save R14 (16 bit data)
... ; Subroutine code
POP R14 ; Restore R14
RET ; Return to lower 64KB
Figure 4-36. Stack After a RET Instruction
199
SLAU144J–December 2004–Revised July 2013 CPUX
Submit Documentation Feedback
Copyright © 2004–2013, Texas Instruments Incorporated