Texas Instruments MSC1210 User Manual
Page 215
Performing Multiplication (MUL)
16-21
8052 Assembly Language
16.19 Performing Multiplication (MUL)
In addition to addition and subtraction, the 8052 also offers the MUL AB in-
struction to multiply two 8-bit values. Unlike addition and subtraction, the MUL
AB instruction always multiplies the contents of the accumulator by the con-
tents of the B register (SFR F0
H
). The result overwrites both the accumulator
and B, placing the low byte of the result in the accumulator and the high byte
of the result in B.
For example, to multiply 20
H
by 75
H
, the following code could be used:
MOV A,#20h
;Load accumulator with 20h
MOV B,#75h
;Load B with 75h
MUL AB
;Multiply A by B
The result of 20
H
S
75
H
is 0EA0
H.
Therefore, after the above MUL instruction,
the accumulator holds the low byte of the answer (A0
H
) and B holds the high
byte of the answer (0E
H
). The original values of the accumulator and B are
overwritten.
If the result is greater than 255, OV is set; otherwise, it is cleared. The carry
bit is always cleared and AC is unaffected.
Note:
Any two 8-bit values may be multiplied using MUL AB and a result will be ob-
tained that fits in the 16 bits available for the result in A and B. This is because
the largest possible multiplication would be (FF
H
S
FF
H
), which would result
in FE01
H
, which comfortably fits into the 16-bit space. It is not possible to
overflow a 16-bit result space with two 8-bit multipliers.