Motorola DSP96002 User Manual
Page 688
MOTOROLA
DSP96002 USER’S MANUAL
B-169
move d6.l,d1.h ; "
ori #$10,ccr ; set infinity bit
ori #$09,ier ; set OVF and INX bits in IER
ori #$09,er ; set OVF and INX bits in ER
jmp _done ; result is infinity
;
; Begin Rounding the Result
;
;
; Check for Denormalized Numbers
;
_rnd move #eden,d7.l ; get denorm exponent
move d6.l,d5.l ; get expr
move #emsk,d4.l ; get exponent mask
and d4,d5 ; delete tags and sign
cmp d7,d5 ; compare exponents
jne _remst ; jump if not a denorm
tst d3 ; test mantr.high
dec d6 ifpl.u ; decrement expr if no int bit
;
; Remove Bits to Right of the Sticky Bit
;
_remst move #smsk,d7.l ; get sticky mask
and d7,d1 ; remove bits right of sticky
;
; Check GRS Bits Equal Zero
;
move d1.l,d5.l ; get register with GRS bits
move #grsmsk,d7.l ; get GRS mask
and d7,d5 ; get GRS bits
tst d5 ; check GRS bits = zero
jeq _lmove ; jump if no rounding required
ori #$1,ier ; set inexact result bit
ori #$1,er ; set inexact result bit
;
; Check Rounding Mode
;
jset #21,sr,_r1chk ; jump if rounding bit r0 = 1
jset #22,sr,_rminf ; jump if round toward -infinity
;
; Round to nearest even
;
jclr #10,d5.l,_lmove ; check guard bit
bclr #10,d5.l ; delete G bit
tst d5 ; check sticky and round bits
jne _addone ; jump if S or R bits = 1
jset #11,d1.l,_addone ; add one if LSB of result = 1
jmp _lmove ; no rounding required
_r1chk jclr #22,sr,_lmove ; jump if round toward zero
;
; Round toward +infinity
;
jclr #31,d6.l,_addone ; add one if positive
jmp _lmove ; get result in d1