Motorola DSP96002 User Manual
Page 685
B-166
DSP96002 USER’S MANUAL
MOTOROLA
jmp _add ;
;
; Set Sticky Bit for Shift > 55 Bits
;
_setst0 move #0,d3.l ; get number for addition
move #inum,d1.l ; "
jmp _add ;
;
; *** Case: Exp1 > Exp0 ***
;
;
; Align Mantissas
;
_pos sub d4,d5 d1.h,d6.l ; get shift, get expr
move #55,d7.l ; get number of bits
cmp d7,d5 ; check for shift > 55
jgt _setst1 ; jump if shift > 55
do d5.l,_end2 ; align mantissas
lsr d2 ; shift right m0.h
ror d0 ; shift right m0.l and GRS0
jclr #8,d0.l,_cclr2 ; jump if sticky bit clear
move #1,d2.m ; set sticky bit
_cclr2 nop ;
;
; Calculate Sticky Bit
;
_end2 move #grmsk,d7.l ; get GR mask
and d7,d0 ; remove bits right of round bit
jclr #0,d2.m,_add ; jump if sticky = 0
bset #8,d1.l ; put in sticky bit
jmp _add ;
;
; Set Sticky Bit for Shift > 55 Bits
;
_setst1 move #0,d2.l ; get number for addition
move #inum,d0.l ; "
;
; Check the Signs of the Addends
;
_add jset #31,d0.h,_neg1 ; jump if a0 negative
jset #31,d1.h,_neg2 ; jump if a1 negative
jmp _fadd ; jump to addition for a0+,a1+
;
; *** Case: Addend 0 is Negative,
; Addend 1 is Positive ***
;
_neg1 jset #31,d1.h,_nset ; jump if a1 negative
sub d0,d1 ; subtract for case: a0-,a1+
subc d2,d3 ; "
jcc _zchk ; jump if result is positive
bset #31,d6.l ; set result as negative
move #inum,d7.l ; get increment number
not d1 ; get 2’s comp of result
not d3 ; "