Divide (32-bit by 16-bit or 16-bit by 16-bit), Multiply (16-bit by 16-bit), Shift right/left – Maxim Integrated High-Speed Microcontroller Users Guide: Network Microcontroller Supplement User Manual

Page 166

Advertising
background image

High-Speed Microcontroller User’s

Guide: Network Microcontroller

Supplement

166

Divide (32-bit by 16-bit or 16-bit by 16-bit)

The divide operation utilizes a 32-bit or 16-bit dividend and a 16-bit divisor. The dividend is loaded into MA (4 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 remain-

der 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 nonzero 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 (nine machine cycles for 32 by 16 divide, six machine cycles for 16 by 16 divide).

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, 3, 10, and 11 not performed for 16-bit dividend.

Multiply (16-bit by 16-bit)

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) is 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 (for six 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).

Shift right/left

The shift function rotates the 32 bits of the MA register as directed by the control bits of the MCNT0 register. MA contains the shifted

results following the operation. Note that the multiplier register shift bits (MCNT.4–0) must be set to a nonzero value, or the normalize

function is performed instead of the desired shift operation.

1. Load MA with data LSB.

2. Load MA with data LSB + 1.

3. Load MA with data LSB + 2.

4. Load MA with data MSB.

5. Configure MCNT0 register as required.

Maxim Integrated

Advertising