Motorola DSP96002 User Manual
Page 675
B-156
DSP96002 USER’S MANUAL
MOTOROLA
tst d3 ; test mantr.high, get expr
dec d5 ifpl.u ; decrement expr if no int bit
_tmov move d5.l,d1.h ; move result to d1
move d0.m,d1.m ; "
move d0.l,d1.l ; "
jmp _done ; a0 is the answer
;
; Both Addends are Zero
;
_bzero move d0.h,d4.l ; get exp0
move d1.h,d5.l ; get exp1
eor d4,d5 ; check for opposite signs
jclr #31,d5.l,_done ; jump if same signs
bclr #31,d1.h ; set result as positive
jclr #22,sr,_done ; jump if round bit r1 = zero
jset #21,sr,_done ; jump if round bit r0 = one
bset #31,d1.h ; set result as negative
jmp _done ; result is negative zero
;
;
;
; ******************************************
; *** DP Addition for Normalized Numbers ***
; ******************************************
;
;
; Compare Exponents
;
_nadd cmp d4,d5 d1.h,d6.l ; compare exps, get expr
jgt _pos ; jump if exp1 > exp0
jeq _add ; jump if exp0 = exp1
;
; *** Case: Exp0 > Exp1 ***
;
;
; Align Mantissas
;
sub d5,d4 d0.h,d6.l ; get shift, get expr
move #55,d7.l ; get number of bits
cmp d7,d4 ; check for shift > 55
jgt _setst0 ; jump if shift > 55
do d4.l,_end1 ; align mantissas
lsr d3 ; shift right m1.h
ror d1 ; shift right m1.l and GRS1
jclr #8,d1.l,_cclr1 ; jump if sticky bit clear
move #1,d2.m ; set sticky bit
_cclr1 nop ;
;
; Calculate Sticky Bit
;
_end1 move #grmsk,d7.l ; get GR mask
and d7,d1 ; remove bits right of round bit
jclr #0,d2.m,_add ; jump if sticky = 0
bset #8,d1.l ; put in sticky bit