home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************************
- ;
- ; $toieee.asm
- ;
- ; staff
- ;
- ; 04-20-88
- ;
- ; (C) Texas Instruments Inc., 1992
- ;
- ; Refer to the file 'license.txt' included with this
- ; this package for usage and license information.
- ;
- ;**************************************************************
- Example 24. TMS320C30 to IEEE conversion (fast version)
- ;
- ;==============================================================================
- ; SUBROUTINE TOIEEE
- ;
- ; FUNCTION: Conversion between the 320C30 format and the IEEE floating point
- ; numbers. The number to be converted is in the upper 32 bits of R0.
- ; The result will be in the lower 32 bits of R0.
- ;
- ; Upon entering the routine, AR1 points to the following table:
- ; (0) 0xFF800000 <-- AR1
- ; (1) 0xFF000000
- ; (2) 0x7F000000
- ; (3) 0x80000000
- ; (4) 0x81000000
- ;
- ; ARGUMENT ASSIGNMENTS:
- ; argument | function
- ; ---------+-----------------------
- ; R0 | number to be converted
- ; AR1 | pointer to table with constants
- ;
- ; REGISTERS USED AS INPUT: R0, AR1
- ; REGISTERS MODIFIED: R0
- ; REGISTER CONTAINING RESULT: R0
- ;
- ; NOTE: Since the stack pointer SP is used, make sure to initialize it
- ; in the calling program.
- ;
- ;
- ; CYCLES: 14 (worst case) WORDS: 15
- ;=============================================================================
- .global TOIEEE
- ;
- TOIEEE LDF R0,R0 ; Determine the sign of the number
- LDFZ *+AR1(4),R0 ; If zero, load appropriate number
- BND NEG ; Branch to NEG if negative (delayed)
- ABSF R0 ; Take the absolute value of the number
- LSH 1,R0 ; Eliminate the sign bit in R0
- PUSHF R0
- POP R0 ; Place number in lower 32 bits of R0
- ADDI *+AR1(2),R0 ; Add exponent bias (127)
- LSH -1,R0 ; Add the positive sign
- RETS
-
-
- NEG POP R0 ; Place number in lower 32 bits of R0
- ADDI *+AR1(2),R0 ; Add exponent bias (127)
- LSH -1,R0 ; Make space for the sign
- ADDI *+AR1(3),R0 ; Add the negative sign
- RETS
-