16
EPSON
S1C63000 CORE CPU MANUAL
CHAPTER 2: ARCHITECTURE
• Return instructions (RET, RETS, RETD, RETI)
A return instruction is used to return from a subroutine called by the call instruction to the routine
that called the subroutine. Return operation is done by loading the PC value (address next to the call
instruction) that was stored in the stack when the subroutine was called into the PC.
The RET instruction operates only to return the PC value in the stack, and the processing is continued
from the address next to the call instruction.
The RETS instruction returns the PC value then adds "1" to the PC. It skips executing an instruction
next to the call instruction.
Figure 2.2.3.3 shows return operations from a subroutine.
Fig. 2.2.3.3 Return from subroutine
The RETD instruction performs the same operation as the RET instruction, then stores the 8-bit data
specified in the operand into the memory specified with the X register. This function is useful to create
data tables that will be explained in the next section.
The RETI instruction is for the exclusive use of hardware and software interrupt service routines.
When an interrupt is generated, the content of the F register is saved into the stack with the current
PC value. The RETI instruction returns them.
• Software interrupt instruction (INT)
The software interrupt instruction "INT imm6" specifies a vector address within the addresses from
0111H to 013FH to execute its interrupt service routine. It can also call a hardware interrupt service
routine because it can specify an address from 0100H. It performs the same operation with the call
instruction, but the F register is also saved into the stack before branching. Consequently, the RETI
instruction must be used for returning from interrupt service routines. See Section 3.5, "Interrupts" for
details of the interrupt.
2.2.4 Table look-up instruction
The RETD instruction, one of the return instructions, has an 8-bit data in the operand, and stores the data
in the memory specified with the X register (the low-order 8 bits are stored in [X] and the high-order 8
bits are stored in [X+1]) immediately after returning.
By using the RETD instruction combined with the "JR %BA" or "JR %A" instructions, an 8-bit data table
for an LCD segment data conversion or similar can simply be constructed in the code ROM.
Example:
The following is an example of a table for converting a BCD data (0 to 9) in the A register
into an ASCII code (30H to 39H). The conversion result is stored in the addresses 0040H
(low-order 4 bits) and 0041H (high-order 4 bits).
LD
%A,3
;Sets data to be converted
CALR TOASCII
;Calls converting routine
LDB
%BA,[%X]+
;Loads result from memory to BA register
:
:
:
:
JR
LD
:
sign8
%A,[%X]
CALR sign8
:
ADD
:
JR
A,B
NC,1
RET (RETD)
Mainroutine
Subroutine
RETS
Address
xxxxH
xxxxH+1
xxxxH+2
Return to
xxxxH+1
Return to
xxxxH+2
Содержание S1C63000
Страница 1: ...MF855 03 Core CPU Manual CMOS 4 BIT SINGLE CHIP MICROCOMPUTER S1C63000 ...
Страница 4: ......