Motorola DSP96002 User Manual

Page 576

Advertising
background image

MOTOROLA

DSP96002 USER’S MANUAL

B-57

dive2big

eor

d2,d2

do

#32,divloop_slow

;same algorithm as 1st routine

rol

d0

rol

d2

cmp

d1,d2

sub

d1,d2

ifhs

divloop_slow rol

d0

not

d0

divdone

end

The final quotient is not produced. This program may calculate only the number of quotient bits required

and has variable execution time.

Unsigned 32 Bit Integer
Remainder of d0 = d0 rem d1, d0>=d1

cmp

d1,d0

d0.l,d2.m

jlo

divdone

;divisor > dividend

bfind

d0,d0

#0,d2.l

jmi

dive2big

;dividend has

;32 significant bits

bfind

d1,d2

d0.h,d0.l

;find # of remainder bits

move

d2.h,d2.l

sub

d0,d2

d2.m,d0.l

inc

d2

d2.l,d2.h

;compute loop count

lsl

d2,d1

d2.l,d2.h

;align divisor

do

d2.l,remloop_fast

cmp

d1,d0

;perform test subtract

sub

d1,d0

ifhs

;if no borrow, perform subtract

rol

d0

;adjust remainder

remloop_fast lsr

d2,d0

;align remainder

jmp

remdone

;done

dive2big

do

#32,remloop_slow

;same algorithm as 1st routine

rol

d0

rol

d2

cmp

d1,d2

sub

d1,d2

ifhs

remloop_slow tfr

d2,d0

remdone

end

B.1.32

Signed Integer Divide

The signed integer divide operation divides two 32 bit signed two’s complement integers. The divide oper-

ation uses a one quadrant restoring divide iteration to divide the operands. The following code divides d5/

d2 with the resulting quotient in d0.

Advertising