Texas Instruments MSC1210 manual Performing Multiplication MUL

Models: MSC1210

1 324
Download 324 pages 20.97 Kb
Page 215
Image 215

Performing Multiplication (MUL)

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 F0H). 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 20H by 75H, 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 20H S 75H is 0EA0H. Therefore, after the above MUL instruction, the accumulator holds the low byte of the answer (A0H) and B holds the high byte of the answer (0EH). 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 (FFH S FFH), which would result in FE01H, which comfortably fits into the 16-bit space. It is not possible to overflow a 16-bit result space with two 8-bit multipliers.

8052 Assembly Language

16-21

 

Page 215
Image 215
Texas Instruments MSC1210 manual Performing Multiplication MUL