English
Language : 

AN1218 Datasheet, PDF (19/56 Pages) Freescale Semiconductor, Inc – HC05 to HC08 Optimization
Freescale Semiconductor, Inc.
Application Note
Stack Pointer
a local variable. The stack of these complex subroutines follow the
generalized structure shown in Figure 6. Figure 6 shows the stack
before the subroutine initialization, before entering the subroutine, and
during the subroutine. The actual cube subroutine is written in the
following section of code. A diagram of the stack during its execution is
given within the code listing.
STACK
SP DURING SUBROUTINE →
$00f7
LOCAL VARIABLE 1
$00F8
LOCAL VARIABLE 2
$00F9
ACCUMULATOR A
$00FA
INDEX REGISTER X
$00FB
PROGRAM COUNTER HIGH $00FC
SP DURING SUBROUTINE → PROGRAM COUNTER LOW $00FD
SP BEFORE
SUBROUTINE INITIALIZATION
→
RETURN VALUE
PASSED PARAMETER
$00FE
$00FF
Code Example
Figure 6. Stack Structure of a Complex Subroutine
Refer to Appendix D — Using the Stack in a Subroutine to Compute
a Cube for an example of modular subroutine code that efficiently
computes the cube of an 8-bit positive number.
AN1218 Rev. 2
19
For More Information On This Product,
Go to: www.freescale.com