Using the arithmetic accelerator, Divide (32/16 or 16/16), Multiply (16 x 16) – Maxim Integrated High-Speed Microcontroller Users Guide: DS80C390 Supplement User Manual
Page 157: Sing the, Rithmetic, Ccelerator

High-Speed Microcontroller User’s Guide: DS80C390 Supplement
157 of 158
USING THE ARITHMETIC ACCELERATOR
The following procedures illustrate how to use the arithmetic accelerator. The MA and MB registers must
be loaded and read in the order shown for proper operation, although accesses to any other registers can
be performed between access to the MA or MB registers. An access to the MA, MB, or MC registers out
of sequence will corrupt the operation, requiring the software to clear the MST bit to restart the math
accelerator state machine.
Divide (32/16 or 16/16)
The divide operation uses a 32- or 16-bit dividend and a 16-bit divisor. The dividend is loaded into MA
(four bytes in the case of a 32-bit dividend, 2 bytes for a 16-bit dividend) and the 16-bit divisor is loaded
into MB. The quotient is stored in MA and the remainder in MB. The optional test of the MOF bit can be
performed to detect a divide-by-0 operation if software has not previously checked for a non-zero divisor.
1. Load MA with dividend LSB.
2. Load MA with dividend LSB+1
*
3. Load MA with dividend LSB+2
*
4. Load MA with dividend MSB.
5. Load MB with divisor LSB.
6. Load MB with divisor MSB.
7. Poll the MST bit until cleared (9 machine cycles).
8. Check MOF bit (MCNT1.6) to see if divide-by-0 occurred. (optional)
9. Read MA to retrieve the quotient MSB.
10. Read MA to retrieve the quotient LSB+2.
**
11. Read MA to retrieve the quotient LSB+1.
**
12. Read MA to retrieve the quotient LSB.
13. Read MB to retrieve the remainder MSB.
14. Read MB to retrieve the remainder LSB.
*Steps 2 and 3 not performed for 16-bit dividend.
**Not performed for 16/16 divide.
Multiply (16 x 16)
This function multiplies two 16-bit values in MA and MB and places the 32-bit product into MA. If the
product exceeds FFFFh then the Multiply Overflow Flag (MOF) will be set.
1. Load MB with multiplier LSB.
2. Load MB with multiplier MSB.
3. Load MA with multiplicand LSB.
4. Load MA with multiplicand MSB.
5. Poll the MST bit until cleared (6 machine cycles).
6. Read MA for product MSB.
7. Read MA for product LSB+2.
8. Read MA for product LSB+1.
9. Read MA for product LSB.
10. Check MOF bit (MCNT1.6) to see if product exceeded FFFFh (optional).