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.

MSB

LSB

4 4 4

YP YH YL

YHL is divided into two 4-bit groups: the four high-

 

 

 

 

 

YHL

 

 

 

 

 

IY

 

 

 

 

 

 

 

 

 

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

Operation

Instruction

Stack usage

Push-down

Interrupt

-3

(SP is decremented)

CALL or CALZ

-3

 

PUSH

-1

 

DEC SP

-1

 

 

 

Pop-up

RET, RETS or RETD

+3

(SP is incremented)

POP

+1

 

INC SP

+1

 

 

 

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:

LD

A,Mn

A

M(n)

 

 

 

 

LD

B,Mn

B

M(n)

 

 

 

LD

Mn,A

M(n) A

 

 

 

LD

Mn,B

M(n) B

 

 

 

 

INC

Mn

M(n)

M(n) + 1

 

 

 

 

DEC

Mn

M(n)

M(n) – 1

 

 

 

 

 

 

 

n: 0 to F

 

 

 

 

 

 

 

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.

S1C6200/6200A CORE CPU MANUAL

EPSON

9