beautypg.com

Motorola DSP96002 User Manual

Page 701

background image

B-182

DSP96002 USER’S MANUAL

MOTOROLA

; extended precision number.

;

; Entry point: ieee2dplib: c(r0)

convert(d0)

;

; Input: r0 contains the lowest address of the 4-word internal

; extended precision number

; d0 contains the DSP96002 floating-point number.

; The DSP96002 has the following floating-point formats:

; SP normalized (24 bit mantissa)

; SP denormalized

; SEP normalized (32 bit mantissa)

; SEP denormalized (encoded as DP normalized)

; DP normalized

; The SP denormalized is encoded using the U tag. All other encodings

; appear the same with varying amount of significand bits.

;

; Output: r0 points to the lowest address of a double precision

; number in non-IEEE double precision format.

;

; Error checking:

; NaNs - Not converted, internal A register not affected

; +/- inf - Limited to maximum internal format value

;

; Alters: D0.L,D1.L,D2.L,D0.H,D1.H

;

ieee2dplib

ftst d0 ;check input

fjor _notnan ;ok if not nan

rts ;no conversion

_notnan fjeq uflow ;if zero, set zero

clr d1 ;get zero for sign

bclr #31,d0.h ;get sign and clear sign bit

inc d1 ifcs ;if sign bit is set, inc

ftst d0 d1.l,x:(r0+sign) ;reset flags, save sign

fjinf oflow ;limit if infinity

jset #30,d0.h,_dodenorm ;do denorm if U tag is set

move d0.m,x:(r0+ms) ;save ms of significand

move d0.l,x:(r0+ls) ;save ls of significand

move d0.h,d0.l ;get dp exponent

move #$1ffffc00,d1.l ;get bias adjustment

add d1,d0 ;new bias

move d0.l,x:(r0) ;set exponent

rts

_dodenorm

move d0.m,d0.l ;get denormed sp significand

bfind d0,d1 ;find first 1

clr d2 d1.h,d1.l ;get a 0, move shift

lsl d1.h,d0 d2.l,x:(r0+ls) ;norm ms, set 0 ls

move d0.l,x:(r0+ms) ;set ms

move #$1fffff81,d0.l ;get exponent

sub d1,d0 ;sub denorm shift to get new bias

move d0.l,x:(r0) ;set exponent

rts