Index register iy, Stack pointer sp, Register pointer rp – Epson 6200A User Manual
Page 15
S1C6200/6200A CORE CPU MANUAL
EPSON
9
2 MEMORY AND OPERATIONS
• Index register IY
Index register IY is like the index register IX: it has a
4-bit page part (YP), an 8-bit register (YHL), and can
address any location in the data memory. See Figure
2.2.1.2.
YHL is divided into two 4-bit groups: the four high-
order bits (YH) and the four low-order bits (YL), and
can address any location within a page.
Fig. 2.2.1.2 The configuration of the index register IY
–
MY is the data memory location whose address is specified by IY.
–
M(Y) refers to the contents of the data memory location whose address is specified by IY.
–
YHL can be incremented by 1 using a post-increment instruction (LDPY, ACPY or SCPY). An
overflow occurring in YHL does not affect the flags.
• Stack pointer SP
The stack area resides in the data memory. The 8-bit, push-down/pop-up stack pointer (SP) is used to
address an element within the stack.
Since it is an 8-bit pointer, SP can only address 256
words out of the total 4,096 words of data memory.
When SP is used, the high-order 4 bits (page part) of
the data memory address are 0, giving a stack area of
256 words in the address range 000H to 0FFH.
In systems with a RAM area of less than 256 words,
the entire RAM area can be used as the stack area.
Stack area usage is shown in Table 2.2.1.2.
Table 2.2.1.2 Stack usage
Push-down
(SP is decremented)
Pop-up
(SP is incremented)
Operation
Instruction
Stack usage
-3
-3
-1
-1
+3
+1
+1
Interrupt
CALL or CALZ
PUSH
DEC SP
RET, RETS or RETD
POP
INC SP
The PUSH instruction can be used to store registers and flags in the stack in single-word (4-bit) units.
The POP instruction is used to retrieve this data.
When an interrupt occurs or a call instruction is executed, the return address from the program counter
is pushed onto the stack. When a return instruction is executed, the return address is retrieved from the
stack and loaded into the program counter.
On an interrupt, only the program counter is saved on the stack; flag and register data are not saved.
Programs should be designed so that flag and register data are pushed onto the stack by the interrupt
service routines.
Following a system reset, SP should be initialized using the LD SPH,r or LD SPL,r instructions, where
r represents A, B, MX or MY (4 bits).
Stack pointer data can be read using LD r,SPH or LD r,SPL.
• Register pointer RP
The register pointer (RP) is a 4-bit register used to address the first 16 words of data memory, or the
register area. Direct addressing can be used to read from, write to, increment or decrement any location
within this area efficiently, using a single instruction.
Programs cannot directly access RP. It uses the
operand of direct addressing instructions. The
instructions that can access the register area of data
memory are:
where M(n) is the contents of a data memory
location within the register area.
As the register area can also be indirectly accessed
using IX, IY or SP, the stack area should not grow
to address 000H to 00FH when RP is used.
LD
LD
LD
LD
INC
DEC
A
←
M(n)
B
←
M(n)
M(n)
←
A
M(n)
←
B
M(n)
←
M(n) + 1
M(n)
←
M(n) – 1
n: 0 to F
A,Mn
B,Mn
Mn,A
Mn,B
Mn
Mn
Y
P
MSB
4
LSB
4
4
Y
H
Y
L
Y
HL
IY