Motorola DSP96002 User Manual

Page 704

Advertising
background image

MOTOROLA

DSP96002 USER’S MANUAL

B-185

abig sub d5,d6 ;c(r0) exponent is greater

cmp d6,d7 #31,d7.l ;is |r0(exp)-r1(exp)| > 63?

jmi aequala ;yes, then c(r0) + c(r1) = c(r0)

cmp d6,d7 #32,d7.l ;is |r0(exp)-r1(exp)| > 31?

jge dshiftx ;no, shift both c(r1) words

sub d7,d6 d2.l,d3.l ;yes, shift ms to ls

clr d2.l d6.l,d0.h ;# of shifts to be performed

lsr d0.h,d3 ;align the mantissas

;

; Add the two mantissas together

;

addmant move x:(r0+sign),d6.l ;get c(r0) sign

move x:(r1+sign),d7.l ;get c(r1) sign

cmp d7,d6 ;are the signs the same?

jmi apos ;c(r0) > 0 and c(r1) < 0

jeq signseq ;c(r0) and X have the same sign

;

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

;

aneg cmp d2,d0 ;compare mantissas

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

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

jeq dp_clr ;clear reg_a if same magnitude

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

r0fromr1 move d7.l,x:(r0+sign) ;make sign positive

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

subc d0,d2 d3.l,d1.l ;calculate c(r0)_ms

move d2.l,d0.l ;put result in c(r0) register

;

; Normalize the result

;

subnorm jeq msis0 ;test ms word

bfind d0,d0 ;find out how many zeros in ms

lsl d0.h,d0 d1.l,d2.l ;shift c(r0)_ms

lsl d0.h,d1 #32,d7.l ;shift c(r0)_ls

move d0.h,d3.l ;copy # of shifts

sub d3,d7 ;# of opposite dir. shifts

move d7.l,d0.h ;move # of shifts to .h reg.

lsr d0.h,d2 ;get bits to go from ls to ms

or d2,d0 ;shift in bits from ls to ms

sub d3,d4 ;decrement the exponent

jmp leave ;make sure the exp is valid

msis0 tst d1.l #32,d3.l ;test if ls is zero

jeq dp_clr ;zero reg_a if yes

bfind d1,d0 d1.l,d0.l ;find out how many zeros in ls

lsl d0.h,d0 d0.h,d2.l ;get bits to go from ls to ms

add d2,d3 ;include shifts from ms

sub d3,d4 #0,d1.l ;decrement the exponent

jmp leave ;make sure the exp is valid

signseq add d3,d1 ;add lower words

addc d2,d0 ;add upper words

addnorm jcc leave ;test for carry

ror d0.l ;normalize the sum

ror d1.l ;shift ms and ls

Advertising