Positive Dividend And Divisor With Remainder - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

Software Techniques
Once all these questions have been answered, it is possible to select the appropriate division algorithm. The
fractional algorithms support a 32-bit signed dividend, and the integer algorithms support a 31-bit signed
dividend. All algorithms support a 16-bit divisor.
Note that the most general division algorithms are the fractional and integer algorithms for four-quadrant
division that generate both a quotient and a remainder. These take the largest number of instruction cycles
to complete and use the most registers.
For extended precision division, where the number of quotient bits required is more than 16, the DIV
instruction and routines presented in this section are no longer applicable. For further information on
division algorithms, consult the following references (or others as required):
Theory and Application of Digital Signal Processing, Lawrence R. Rabiner and Bernard Gold
(Prentice-Hall: 1975), pages 524–530.
Computer Architecture and Organization, John Hayes (McGraw-Hill: 1978), pages 190–199.
8.4.1

Positive Dividend and Divisor with Remainder

The algorithms in the following code are the fastest and take the least amount of program memory. In order
to use these algorithms, it must be guaranteed that both the dividend and divisor are both positive, signed,
two's-complement numbers. One algorithm is presented for the division of fractional numbers and a
second is presented for the division of integer numbers. Both algorithms generate the correct positive
quotient and positive remainder.
; Division of Fractional, Positive Data (B1:B0 / X0)
BFCLR
REP
DIV
ADD
; Division of Integer, Positive Data (B1:B0 / X0)
ASL
BFCLR
REP
DIV
MOVE
ADD
ASR
8-14
#$0001,SR
; Clear carry bit: required for first DIV
16
X0,B
;Form positive quotient in B0
X0,B
;Restore remainder in B1
;(At this point, the positive quotient is
; in B0 and the positive remainder is in B1)
B
;Shift of dividend required for integer
; division
#$0001,SR
;Clear carry bit: required for first DIV
16
X0,B
;Form positive quotient in B0
B0,Y1
;Save quotient in Y1
;(At this point, the positive quotient is in
; B0 but the remainder is not yet correct)
X0,B
;Restore remainder in B1
B
;Required for correct integer remainder
;(At this point, the correct positive
; remainder is in B1)
DSP56800 Family Manual

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents