MSP430 Instructions
4-97
16-Bit MSP430X CPU
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 four MSBs of the program counter PC.19:16
are cleared.
Status Bits
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
64K 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. The Stack After a RET Instruction
Item n
PC
Return
Item n
Stack before RET
Stack after RET
SP
SP
instruction
instruction
Summary of Contents for MSP430x4xx Family
Page 1: ...MSP430x4xx Family 2007 Mixed Signal Products User s Guide SLAU056G ...
Page 2: ......
Page 6: ...vi ...
Page 114: ...3 76 RISC 16 Bit CPU ...
Page 304: ...5 20 FLL Clock Module ...
Page 340: ...7 8 Supply Voltage Supervisor ...
Page 348: ...8 8 16 Bit Hardware Multiplier ...
Page 372: ...9 24 32 Bit Hardware Multiplier ...
Page 400: ...10 28 DMA Controller ...
Page 428: ...13 10 Basic Timer1 ...
Page 466: ...15 24 Timer_A ...
Page 522: ...17 30 USART Peripheral Interface UART Mode ...
Page 544: ...18 22 USART Peripheral Interface SPI Mode ...
Page 672: ...23 12 Comparator_A ...
Page 692: ...24 20 LCD Controller ...
Page 746: ...26 28 ADC12 ...