Texas Instruments TMS320C3x User Manual

Page 123

Advertising
background image

Floating-Point Conversion (IEEE Std. 754)

5-18

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

*

NOTE:

SINCE THE STACK POINTER SP IS USED, MAKE SURE TO

*

INITIALIZE IT IN THE CALLING PROGRAM.

*
*

*

CYCLES: 12 (WORST CASE) WORDS: 12

*

.global FMIEEE

*

FMIEEE

AND3

R0,*AR1,R1

; Replace fraction with 0

BND

NEG

; Test sign

ADDI

R0,R1

; Shift sign
; and exponent inserting 0

LDIZ

*+AR1(1),R1

; If all 0, generate C30 0

SUBI

*+AR1(2),R1

; Unbias exponent

PUSH

R1

POPF

R0

; Load this as a flt. pt. number

RETS

*
NEG

PUSH

R1

POPF

R0

; Load this as a flt. pt. number

NEGF

R0,R0

; Negate if orig. sign is negative

RETS

Example 5–5 shows the complete conversion between IEEE and ’C3x formats.
In addition to the general case and the 0s, it handles the special cases as follows:

-

If NaN (e = 255, f < > 0), the number is returned intact.

-

If infinity (e = 255, f = 0), the output is saturated to the most positive or nega-
tive number, respectively.

-

If denormalized (e = 0, f< >0), two cases are considered. If the MSB of f is
1, the number is converted to ’C3x format. Otherwise an underflow occurs,
and the number is set to 0.

Advertising