
CHAPTER 3 REGISTERS
3.2Program Counter (PC) and Stack Pointer (SP)
The program counter (PC) and stack pointer (SP) are
The program counter (PC) indicates the address of the location at which the instruction currently being executed is stored.
The stack pointer (SP) holds the addresses of the data location to be referenced by the interrupt and stack push/pop instructions. The value of the current stack pointer (SP) indicates the address at which the last data pushed onto the stack is stored.
■Program Counter (PC)
Figure 3.2-1 shows the operation of the program counter (PC).
Figure 3.2-1 Program Counter Operation
Before execution
PC 1234H
MEMORY |
|
| After execution |
| MEMORY | ||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| PC | 1235H |
|
| 1235H |
|
|
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
| XXH |
| |
|
|
|
|
|
|
|
|
|
| ||
1234H | 00H |
| Instruction "NOP" executed |
| 1234H | 00H |
| ||||
|
|
|
| ||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
■Stack Pointer (SP)
Figure 3.2-2 shows the operation of the stack pointer (SP).
Figure 3.2-2 Stack Pointer Operation
Before execution |
| MEMORY |
|
| After execution | ||||||
A |
|
|
| 5679H |
|
|
|
|
|
|
|
1234H |
|
| XXH |
|
|
| A | 1234H |
| ||
|
|
|
|
|
| ||||||
|
|
|
| 5678H |
|
|
|
|
|
|
|
|
|
|
| XXH |
|
|
|
|
|
| |
SP | 5678H |
|
|
|
|
| SP | 5676H |
| ||
|
| 5677H |
|
|
|
|
| ||||
|
|
|
|
| |||||||
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
| 5676H |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
| PUSHW A |
|
| |||
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
|
|
|
MEMORY
|
|
|
5679H | XXH | |
|
|
|
5678H | XXH | |
|
|
|
5677H | 32H | |
|
|
|
| 5676H | 12H |
| ||
|
|
|
|
|
|
17