111
AT94KAL Series FPSLIC
Rev. 1138G–FPSLI–11/03
16-bit Multiply-
accumulate Operation
Figure 63.
16-bit Multiplication, 32-bit Accumulated Result
Using Fractional
Numbers
Unsigned 8-bit fractional numbers use a format where numbers in the range [0, 2> are
allowed. Bits 6 - 0 represent the fraction and bit 7 represents the integer part (0 or 1), i.e. a 1.7
format. The FMUL instruction performs the same operation as the MUL instruction, except that
the result is left-shifted 1 bit so that the high byte of the 2-byte result will have the same 1.7 for-
mat as the operands (instead of a 2.6 format). Note that if the product is equal to or higher
than 2, the result will not be correct.
To fully understand the format of the fractional numbers, a comparison with the integer num-
ber format is useful: Table 20 illustrates the two 8-bit unsigned numbers formats. Signed
fractional numbers, like signed integers, use the familiar two’s complement format. Numbers in
the range [-1, 1> may be represented using this format.
If the byte “1011 0010” is interpreted as an unsigned integer, it will be interpreted as 128 + 32
+ 16 + 2 = 178. On the other hand, if it is interpreted as an unsigned fractional number, it will
be interpreted as 1 + 0.25 + 0.125 + 0.015625 = 1.390625. If the byte is assumed to be a
signed number, it will be interpreted as 178 - 256 = -122 (integer) or as 1.390625 - 2 =
-0.609375 (fractional number).
AH
AL
BH
BL
X
AL * BL
AL * BH
AH * BL
AH * BH
+
+
+
(sign ext)
(sign
ext)
(sign
ext)
=
CH
CMH
CML
CL
+
CH
CL
( Old )
( New )
CMH
CML