Texas Instruments TMS320C3x User Manual

Page 125

Advertising
background image

Floating-Point Conversion (IEEE Std. 754)

5-20

Example 5–5.IEEE-to-TMS320C3x Conversion (Complete Version) (Continued)

*

HANDLE NaN AND INFINITY

TSTB

*+AR1(7),R0

RETSNZ

;

Return if NaN

LDI

R0,R0

LDFGT

*+AR1(8),R0

;

If positive, infinity =

;

most positive number

LDFN

*+AR1(5),R0

;

If negative, infinity =

RETS

;

most negative number RETS

*

HANDLE 0s AND UNNORMALIZED NUMBERS

UNNORM

TSTB

*+AR1(6),R0

;

Is the MSB of f equal to 1?

LDFZ

*+AR1(3),R0

;

If not, force the number to 0

RETSZ

;

and return

XOR

*+AR1(6),R0

;

If MSB of f = 1, make it 0

BND

NEG1

LSH

1,R0

;

Eliminate sign bit

;

& line up mantissa

SUBI

*+AR1(2),R0

;

Make e =

±

127

PUSH

R0

POPF

R0

;

Put number in floating point format

RETS

NEG1

POPF

R0

NEGF

R0,R0

;

If negative, negate R0

RETS

*

HANDLE THE REGULAR CASES

*
NORMAL

AND3

R0,*AR1,R1

;

Replace fraction with 0

BND

NEG

;

Test sign

ADDI

R0,R1

;

Shift sign and exponent inserting 0

SUBI

*+AR1(2),R1

;

Unbias exponent

PUSH

R1

POPF

R0

;

Load this as a flt. pt. number

RETS

NEG

POPF

R0

;

Load this as a flt. pt. number

NEGF

R0,R0

;

Negate if original sign negative

RETS

Advertising