21 Multiplier/Divider (COPRO)
S1C17F13 TeChniCal Manual
Seiko epson Corporation
21-3
(Rev. 1.0)
3.1 Operation in Multiplication Mode
Table 21.
Mode set-
ting value
Instruction
Operations
Flags
Remarks
0x04
or 0x05
ld.ca %rd,%rs
res[31:0]
←
%rd
×
%rs
%rd
←
res[15:0]
psr (CVZN)
←
0b0000 The operation result register
keeps the operation result until
it is rewritten by other opera-
tion.
(
ext
imm9
)
ld.ca %rd,
imm7
res[31:0]
←
%rd
×
imm7/16
%rd
←
res[15:0]
0x14
or 0x15
ld.ca %rd,%rs
res[31:0]
←
%rd
×
%rs
%rd
←
res[31:16]
(
ext
imm9
)
ld.ca %rd,
imm7
res[31:0]
←
%rd
×
imm7/16
%rd
←
res[31:16]
res: operation result register
Example:
ld.cw %r0,0x4 ;
Sets the mode (unsigned multiplication mode and 16 low-order bits output mode).
ld.ca %r0,%r1 ;
Performs “res = %r0
×
%r1” and loads the 16 low-order bits of the result to %r0.
ld.cw %r0,0x13 ;
Sets the mode (operation result read mode and 16 high-order bits output mode).
ld.ca %r1,%r0 ;
Loads the 16 high-order bits of the result to %r1.
Division
21.4
The division function performs “B (16 bits)
÷
C (16 bits) = A (16 bits), residue D (16 bits).”
The following shows a procedure to perform a division:
1. Set the mode to 0x08 (unsigned division, 16 low-order bits output mode) or 0x09 (signed division, 16 low-order
bits output mode).
2. Send the 16-bit dividend (B) and 16-bit divisor (C) to COPRO using a “
ld.ca
” instruction.
3. Read the one-half result (16 low-order bits = quotient) and the flag status.
4. Set the mode to 0x13 (operation result read, 16 high-order bits output mode).
5. Read another one-half result (16 high-order bits = residue).
Operation result
register
Selector
Argument 2
Argument 1
16 bits
16 bits
Coprocessor
output (16 bits)
Flag output
Operation
result
÷
S1C17 Core
COPRO
4.1 Data Path in Division Mode
Figure 21.
4.1 Operation in Division Mode
Table 21.
Mode set-
ting value
Instruction
Operations
Flags
Remarks
0x08
or 0x09
ld.ca %rd,%rs
res[31:0]
←
%rd
÷
%rs
%rd
←
res[15:0] (quotient)
psr (CVZN)
←
0b0000 The operation result register
keeps the operation result until
it is rewritten by other opera-
tion.
(
ext
imm9
)
ld.ca %rd,
imm7
res[31:0]
←
%rd
÷
imm7/16
%rd
←
res[15:0] (quotient)
0x018
or 0x19
ld.ca %rd,%rs
res[31:0]
←
%rd
÷
%rs
%rd
←
res[31:16] (residue)
(
ext
imm9
)
ld.ca %rd,
imm7
res[31:0]
←
%rd
÷
imm7/16
%rd
←
res[31:16] (residue)
res: operation result register