CENTRAL PROCESSING UNIT (CPU)
2.1 Central processing unit (CPU)
2.1.4 Stack pointer (S)
The stack pointer (S) is a 16-bit register. It is used for a subroutine call or an interrupt. It is also used when
addressing modes using the stack are executed. The contents of S indicate an address (stack area) for
storing registers during subroutine calls and interrupts. Bank 016 is specified for the stack area. (Refer to
section
“2.3 Access space.”)
When an interrupt request is accepted, the microcomputer stores the contents of the program bank register
(PG) at the address indicated by the contents of S and decrements the contents of S by 1. Then the
contents of the program counter (PC) and the processor status register (PS) are stored. The contents of
S after accepting an interrupt request is equal to the contents of S decremented by 5 before accepting of
the interrupt request. (See Figure 2.1.2.)
When completing the process in the interrupt routine
and returning to the original routine, the contents of
Stack area
registers stored in the stack area are restored into
Address
the original registers in the reverse sequence
S–5
(PS→PC→PG) by executing the
RTI
instruction. The
contents of S is returned to the state before accepting
S–4
Processor status register’s low-order byte (PS
L
)
an interrupt request.
S–3
Processor status register’s high-order byte (PS
H
)
The same operation is performed during a subroutine
Program counter’s low-order byte (PC
L
)
S–2
call, however, the contents of PS is not automatically
stored. (The contents of PG may not be stored.
Program counter’s high-order byte (PC
H
)
S–1
This depends on the addressing mode.)
Program bank register (PG)
S
During interrupts or subroutine calls, the other
registers are not automatically stored. Therefore, if
the contents of these registers need to be held on,
q
“S” is the initial address that the stack pointer (S)
indicates at accepting an interrupt request.
be sure to store them by software.
The S’s contents become “S – 5” after storing the
Additionally, the S’s contents become “0FFF
16
” at
above registers.
reset. The stack area changes when subroutines
are nested or when multiple interrupt requests are
accepted. Therefore, make sure of the subroutine’s
Fig. 2.1.2 Contents of stack area after accepting
interrupt request
nesting depth not to destroy the necessary data.
❈
Refer to “7900
Series Software Manual”
for addressing modes and instructions.
2-4
7905 Group User’s Manual Rev.1.0