RTS

RTS

Return From Subroutine (AGU)

Operation

 

Assembler Syntax

If (RAS valid), then RAS → PC;

RTS

 

else (SP – 8) → PC;

 

always SP – 8 → SP

RTS

Description

RTS

Returns from a subroutine. If the RAS is valid, the PC is restored from the RAS. Otherwise, the PC is popped from the active stack in memory as a 32-bit long word. The stack pointer always decrements by 8, RAS becomes invalid, and program execution continues at the address specified in the PC.

Note: Because RTS uses the RAS mechanism, returning from an exception using RTS is illegal. The result is undefined.

Status and Conditions that Affect Instruction

Register Address

Bit Name

Description

SR[18]

EXP

Determines which stack pointer is used.

Status and Conditions Changed by Instruction

None.

Example

rts

Register/Memory Address

SR

ESP

($2000)

RAS

PC

Before

$00E4 0000

$0000 2008

$0000 0018

$0000 0018

$0000 0026

After

$0000 2000

$0000 0018

A-370

SC140 DSP Core Reference Manual

Page 684
Image 684
Freescale Semiconductor SC140 specifications Rts, Return From Subroutine AGU, If RAS valid, then RAS → PC