XC2200 Derivatives
System Units (Vol. 1 of 2)
Central Processing Unit (CPU)
User’s Manual
4-62
V2.1, 2008-08
CPUSV2_X, V2.2
4.8.3
Multiply and Divide Unit
The XC2200’s multiply and divide unit has two separated parts. One is the fast 16
×
16-bit multiplier that executes a multiplication in one CPU cycle. The other one is a
division sub-unit which performs the division algorithm in 18 … 21 CPU cycles
(depending on the data and division types). The divide instruction requires four CPU
cycles to be executed. For performance reasons, the rest of the division algorithm runs
in the background during the following seventeen CPU cycles, while further instructions
are executed in parallel. Interrupt tasks can also be started and executed immediately
without any delay. If an instruction (from the original instruction stream or from the
interrupt task) tries to use the unit while a division is still running, the execution of this
new instruction is stalled until the previous division is finished.
To avoid these stalls, the multiply and division unit should not be used during the first
fourteen CPU cycles of the interrupt tasks. For example, this requires up to fourteen one-
cycle instructions to be executed between the interrupt entry and the first instruction
which uses the multiply and divide unit again (worst case).
Multiplications and divisions implicitly use the 32-bit multiply/divide register MD
(represented by the concatenation of the two non-bit-addressable data registers MDH
and MDL) and the associated control register MDC. This bit-addressable 16-bit register
is implicitly used by the CPU when it performs a division or multiplication in the ALU.
After a multiplication, MD represents the 32-bit result. For long divisions, MD must be
loaded with the 32-bit dividend before the division is started. After any division, register
MDH represents the 16-bit remainder, register MDL represents the 16-bit quotient.
MDH
Multiply/Divide High Reg.
SFR (FE0C
H
/06
H
)
Reset Value: 0000
H
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
mdh
rwh
Field
Bits
Type
Description
mdh
[15:0]
rwh
High Part of MD
The high order sixteen bits of the 32-bit multiply and
divide register MD.