dsp56800e Freescale Semiconductor, Inc, dsp56800e Datasheet - Page 169

no-image

dsp56800e

Manufacturer Part Number
dsp56800e
Description
16-bit Digital Signal Controller Core
Manufacturer
Freescale Semiconductor, Inc
Datasheet
5.3.4.2
If both the dividend and divisor are positive, signed, two’s-complement numbers, a more efficient
algorithm can replace the general-purpose four-quadrant approach. Consider a simple positive division
with a remainder, such as the following:
This operation can be calculated correctly with the code presented in Example 5-16. The algorithms in this
code are the fastest and require the least amount of program memory. The example presents different
algorithms for the division of fractional and integer numbers. Both algorithms generate the correct positive
quotient and positive remainder.
; Division of Positive Fractional Data (B1:B0 / X0)
; Division of Positive Integer Data (B1:B0 / X0)
5.3.4.3
An algorithm that is slightly more complex but still more efficient than the general-purpose algorithm can
be used for signed values when a correct remainder is not required.
The algorithms in Example 5-17 on page 5-24 are faster than the general-purpose algorithms because they
generate the quotient only; they do not generate a correct remainder. The example presents different
algorithms for the division of fractional and integer numbers.
Freescale Semiconductor
64
÷
BFCLR
REP
DIV
ADD
ASL
BFCLR
REP
DIV
MOVE.W
ADD
ASR
Positive Dividend and Divisor with Remainder
Signed Dividend and Divisor with No Remainder
9 = 7 (remainder 1)
#$0001,SR
16
X0,B
X0,B
B
#$0001,SR
16
X0,B
B0,Y1
X0,B
B
Example 5-16. Unsigned Division with Remainder
Data Arithmetic Logic Unit
; Clear carry bit: required for 1st DIV instruction
; Form positive quotient in B0
; Restore remainder in B1
; (At this point, the positive quotient is in
; B0 and the positive remainder is in B1)
; Shift of dividend required for integer
; division
; Clear carry bit: required for 1st DIV instruction
; Form positive quotient in B0
; Save quotient in Y1
; (At this point, the positive quotient is in
; B0 but the remainder is not yet correct)
; Restore remainder in B1
; Required for correct integer remainder
; (At this point, the correct positive
; remainder is in B1)
Fractional and Integer Arithmetic
5-23

Related parts for dsp56800e