Page 128 - Understanding Automotive Electronics
P. 128
2735 | CH 4 Page 115 Tuesday, March 10, 1998 11:06 AM
MICROCOMPUTER INSTRUMENTATION AND CONTROL 4
Figure 4.10
Jump-to-Subroutine
FPO
For a jump-to-subrou- Now refer back to Figure 4.4. There is a register in Figure 4.4 called the
tine, the contents of the stack pointer (SP). The address of the special memory location used to store the
program counter (after program counter content is kept in this 16-bit stack pointer register. When a
being incremented) are jump-to-subroutine op code is encountered, the CPU uses the number code
stored in two memory contained in the stack pointer as a memory address to store the program
locations pointed to by counter to memory (step 2b of Figure 4.10). The program counter is a 2-byte
the stack pointer. After register, so it must be stored in two memory locations. The current stack
storing them, the stack pointer is used as an address to store the lower byte of the program counter to
pointer value is memory (step 6). Then the stack pointer is decremented (decreased by one) and
decreased by one to pre- the high byte of the program counter is stored in the next lower memory
pare it for the next store. location (step 7). The stack pointer is then decremented again to point to the
next unused byte in the stack to prepare for storing the program counter again
when required (step 8).
UNDERSTANDING AUTOMOTIVE ELECTRONICS 115