dsp56800e Freescale Semiconductor, Inc, dsp56800e Datasheet - Page 254

no-image

dsp56800e

Manufacturer Part Number
dsp56800e
Description
16-bit Digital Signal Controller Core
Manufacturer
Freescale Semiconductor, Inc
Datasheet
Program Controller
Note that if the fast interrupt processing method is used to handle an interrupt, the process is quite
different, and it does not involve a JSR to an interrupt service routine. For more information on both types
of interrupt processing, see Section 9.3.2, “Interrupt and Exception Processing,” on page 9-4.
8.3.4
The software stack supports structured programming techniques, such as parameter passing to subroutines
and local variables. These techniques can be used for both assembly language programming as well as
high-level language compilers.
Parameters can be passed to a subroutine by placing these variables on the software stack immediately
before a JSR to the subroutine is performed. Placing these variables on the stack is referred to as building a
“stack frame.” These passed parameters can then be accessed in the called subroutine with the use of
SP-relative addressing modes. This process is demonstrated in Example 8-4.
Variables that are local to a subroutine can also be conveniently allocated on the stack. Stack locations that
are above the status register and return address can be set aside for local variables by incrementing the
stack pointer the required number of words. Local variables can then be accessed relative to the stack
pointer, as subroutine parameters are. Example 8-4 also illustrates the creation and use of local variables
on the stack.
ROUTINE1
;
;
The stack frame created by the code in Example 8-4 is shown in Figure 8-4 on page 8-17.
8-16
Parameter Passing and Local Variables
ADDA
MOVE.W
MOVE.W
MOVE.W
MOVE.W
JSR
SUBA
ADDA
(instructions)
MOVEU.W
MOVE.W
MOVE.W
ADD
MOVE.W
(other instructions...)
SUBA
RTS
Example 8-4. Subroutine Call with Passed Parameters
#1,SP
X:$35,X0
X0,X:(SP)+
X:$21,X0
X0,X:(SP)
ROUTINE1
#2,SP
#4,SP
X:(SP-7),R0
X:(SP-6),B
X:(R0),X0
X0,B
B,X:(SP-6)
#4,SP
DSP56800E Core Reference Manual
; (pre-increment before pushing two variables)
; Pointer variable to be passed to subroutine
; (push onto stack)
; 2nd variable to be passed to subroutine
; (push onto stack)
; *** Execute Subroutine ***
; Remove the two passed parameters from
; stack when done
; Allocate room for local variables
; Get pointer variable
; Get 2nd variable
; Get data pointed to by pointer variable
; Store sum in 2nd variable
Freescale Semiconductor

Related parts for dsp56800e