Motorola DSP96002 User Manual

Page 714

Advertising
background image

MOTOROLA

DSP96002 USER’S MANUAL

B-195

inc d0 ifcs ;if odd exponent, use 2 bits

add d2,d1 ;restore exponent bias

move d1.l,x:(r0) ;store it

move x:(r0+ms),d7.l ;get ms

move x:(r0+ls),d6.l ;get ls

clr d4 #0,d5.l ;clear RR

clr d3 #0,d2.l ;clear DR

do d0.l,_initshift ;initial shift

lsl d6 ;shift 2 bits from d7:d6 (SQR)

rol d7

rol d4 ;to d5:d4 (RR)

rol d5

_initshift

do #62,_sqrt ;take root of SQR into DR

lsl d2 d4.l,d0.l ;(dr<<2)|1, copy rr

rol d3 d5.l,d1.l

lsl d2

rol d3

inc d2 ;set lsb

sub d2,d0 ;temp=rr-(dr<<2)|1

subc d3,d1

jcs _ofl ;overflow

lsr d3 d0.l,d4.l ;shift dr back only 1 bit

ror d2 d1.l,d5.l ;rr=temp

inc d2 ;root bit=1

jmp _next

_ofl lsr d3 ;shift dr back only 1 bit

ror d2 ;root bit=0

_next lsl d6 ;shift 2 bits from d7:d6 (SQR)

rol d7

rol d4 ;to d5:d4 (RR)

rol d5

lsl d6 ;shift 2 bits from d7:d6 (SQR)

rol d7

rol d4 ;to d5:d4 (RR)

rol d5

_sqrt lsl d2 ;adjust to msb

rol d3

lsl d2 ;adjust to msb

rol d3

move d3.l,x:(r0+ms) ;save ms part

move d2.l,x:(r0+ls) ;save ls part

rts

;

; MOTOROLA DSP96002 DPLIB - VERSION 1.0
;
; DP_SUB - Double precision subtraction.
;

; Entry point: dp_sub: c(r0)

c(r0) - c(r1)

;

; Inputs: r0 contains the lowest address of a 4-word internal

; extended precision number

; r1 contains the lowest address of a 4-word internal

Advertising