
Item n
PC
Return
Item n
Stack before RET
instruction
Stack after RET
instruction
SP
SP
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 64 K), 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 64 K and return to the address in the lower 64 K
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 64 K
Figure 4-37. Stack After a RET Instruction
169
SLAU272C – May 2011 – Revised November 2013
CPUX
Copyright © 2011–2013, Texas Instruments Incorporated