beautypg.com

Motorola DSP96002 User Manual

Page 705

background image

B-186

DSP96002 USER’S MANUAL

MOTOROLA

inc d4.l ;increment the exponent

jmp leave ;check for overflow

;

; Calculate the result assuming that c(r0) > 0 and X < 0

;

apos cmp d2,d0 ;compare mantissas

jne decide ;if ms’s are equal, test ls’s

cmp d3,d1 #1,d7.l ;compare ls of mantissas

jeq dp_clr ;clear reg_a if same magnitude

decide jcc r1fromr0 ;if c(r0) > c(r1), c(r0) - c(r1)

jmp r0fromr1 ;subtract c(r0) from c(r1)

r1fromr0 sub d3,d1 ;subtract c(r1) from c(r0)

subc d2,d0 ;calculate c(r0)_ms

jmp subnorm ;normalize result

;

; Shift the c(r0) 64 bit significand

;

dshifta move d5.l,d0.h ;# of shifts in .h register

lsr d0.h,d1 d0.l,d6.l ;shift ls, copy ms

lsr d0.h,d0 #32,d7.l ;shift ms

sub d5,d7 ;calc. # opposite dir. shifts

move d7.l,d0.h ;# of shifts in .h register

lsl d0.h,d6 ;get bits to be shifted to ls

or d6,d1 ;shift in bits from ms to ls

jmp addmant

;

; Shift the c(r1) 64 bit significand

;

dshiftx move d6.l,d0.h ;# of shifts in .h register

lsr d0.h,d3 d2.l,d1.h ;shift ls, copy ms

lsr d0.h,d2 #32,d7.l ;shift ms

sub d6,d7 d1.h,d6.l ;calc. # opposite dir. shifts

move d7.l,d0.h ;# of opposite dir. shifts

lsl d0.h,d6 ;get bits to be shifted to ls

or d6,d3 ;shift in bits from ms to ls

jmp addmant

;

; Replace c(r0) with c(r1) (c(r0) is insignificant compared to c(r1))

;

aequalx move x:(r1+sign),d0.l

move d0.l,x:(r0+sign) ;c(r0)_sign

c(r1)_sign

move d3.l,x:(r0+ls) ;c(r0)_ls

c(r1)_ls

move d2.l,x:(r0+ms) ;c(r0)_ms

c(r1)_ms

move d4.l,x:(r0) ;c(r0)_exp

c(r1)_exp

;

; Leave c(r0) unchanged (c(r1) is insignificant compared to c(r0))

;

aequala rts

;

; Place the result of the operation in c(r0)

;

leave move d0.l,x:(r0+ms) ;store c(r0)_ms

move d1.l,x:(r0+ls) ;store c(r0)_ls

move d4.l,x:(r0) ;store c(r0) exponent