Item n
PC
Return
Item n
Stack before RET
instruction
Stack after RET
instruction
SP
SP
Instruction Set Description
196
SLAU367P – October 2012 – Revised April 2020
Copyright © 2012–2020, Texas Instruments Incorporated
CPUX
4.6.2.36 RET
* RET
Return from subroutine
Syntax
RET
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 4 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