Freescale Semiconductor SC140 specifications Fast Return from Subroutines

Models: SC140

1 760
Download 760 pages 48.94 Kb
Page 216
Image 216

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.

5-36

SC140 DSP Core Reference Manual

Page 216
Image 216
Freescale Semiconductor SC140 specifications Fast Return from Subroutines