KS57C2308/P2308/C2316/P2316 ADDRESS SPACES
2-11
++ PROGRAMMING TIPSelecting the Working Register Area
The following examples show the correct programming method for selecting working register area:
1. When ERB = "0":
VENT2 1,0,INT0 ;EMB 1, ERB 0, Jump to INT0 address
INT0 PUSH SB ;PUSH current SMB, SRB
SRB 2;Instruction does not execute because ERB = "0"
PUSH HL ;PUSH HL register contents to stack
PUSH WX ;PUSH WX register contents to stack
PUSH YZ ;PUSH YZ register contents to stack
PUSH EA ;PUSH EA register contents to stack
SMB 0
LD EA,#00H
LD 80H,EA
LD HL,#40H
INCS HL
LD WX,EA
LD YZ,EA
POP EA ;POP EA register contents from stack
POP YZ ;POP YZ register contents from stack
POP WX ;POP WX register contents from stack
POP HL ;POP HL register contents from stack
POP SB ;POP current SMB, SRB
IRET
The POP instructions execute alternately with the PUSH instructions. If an SMB n instruction is used in an
interrupt service routine, a PUSH and POP SB instruction must be used to store and restore the current SMB and
SRB values, as shown in Example 2 below.
2. When ERB = "1":
VENT2 1,1,INT0 ;EMB 1, ERB 1, Jump to INT0 address
INT0 PUSH SB ;Store current SMB, SRB
SRB 2;Select register bank 2 because of ERB = "1"
SMB 0
LD EA,#00H
LD 80H,EA
LD HL,#40H
INCS HL
LD WX,EA
LD YZ,EA
POP SB ;Restore SMB, SRB
IRET