5 fast return from subroutines, Fast return from subroutines -36, Refer to – Freescale Semiconductor StarCore SC140 User Manual
Page 216: Section 5.5.5, “fast return from subroutines, For a more detailed

5-36
SC140 DSP Core Reference Manual
Stack Support
5.5.5 Fast Return from Subroutines
The SC140 supports a mechanism for speeding up the execution of the return from subroutine (RTS)
instruction, using a return address stack (RAS) register. The RAS is updated with the return address during
the execution of a JSR or BSR instruction.
Normal execution of an RTS takes five to six execution cycles. If the routine performing the RTS is a leaf
routine (meaning that no other RTS has been executed between the jump to this subroutine and the
execution of the RTS), then RTS executes in three cycles. Upon RTS, the RAS is invalidated until the next
JSR or BSR instruction.
The user is not allowed to create a situation where upon using RTS, the RAS is valid but the return address
does not match the one that is stored in the stack. This situation may occur if the user explicitly changed
the return address in the stack. See Rule J.4 in
Chapter 7, “Programming Rules.”
The RTSTK instruction can be used to bypass the special logic that implements this fast RTS mechanism.
This instruction retrieves the return address from the stack also when the RAS is valid. RTSTK is typically
used when the return address from subroutine is explicitly changed in the stack.