Page 177 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 177
154 Chapter 6 Assembly Language Subroutines
Figure 6.20. Location of Parameters Passed on the Hardware Stack
* SUBROUTINE DOTPRD - LOCAL VARIABLES
TERM: EQU 0 ; First term of the dot product
MBYTES: EQU 2
* PARAMETERS
RETN: EQU 2 ; Return address
LOCV: EQU 4
LOCW: EQU 6
LOCDP: EQU 8
DOTPRD: LEAS -NBYTES,SP ; Allocation for local variables
LDAA LOCV,SP
LDAB LOCW,SP
MUL
STD TERM, SP ; Copy first term to local variables
LDAA LOCV+1,SP
LDAB LOCW+l fSP
MUL
ADDD TERM, SP ; Dot product into D
STD LOCDP, SP ; Place dot product in output parameter
LEAS NBYTES, SP ; Deallocate local variables
RTS
Figure 6.21. A Subroutine with Parameters on the Stack