home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / coding / dsp / c30ug.exe / $TOIEEE.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-04-20  |  2.0 KB  |  67 lines

  1. ;**************************************************************
  2. ;  
  3. ;                 $toieee.asm
  4. ;  
  5. ;                 staff
  6. ;  
  7. ;                 04-20-88
  8. ;  
  9. ;           (C) Texas Instruments Inc., 1992 
  10. ;  
  11. ;           Refer to the file 'license.txt' included with this 
  12. ;           this package for usage and license information. 
  13. ;  
  14. ;**************************************************************
  15. Example 24.  TMS320C30 to IEEE conversion (fast version)
  16. ;
  17. ;==============================================================================
  18. ;             SUBROUTINE   TOIEEE
  19. ;
  20. ; FUNCTION: Conversion between the 320C30 format and the IEEE floating point
  21. ;    numbers.  The number to be converted is in the upper 32 bits of R0.
  22. ;    The result will be in the lower 32 bits of R0.
  23. ;
  24. ;    Upon entering the routine, AR1 points to the following table:
  25. ;    (0)    0xFF800000 <-- AR1
  26. ;    (1)    0xFF000000
  27. ;    (2)    0x7F000000
  28. ;    (3)    0x80000000
  29. ;    (4)    0x81000000
  30. ;
  31. ; ARGUMENT ASSIGNMENTS:
  32. ;   argument | function
  33. ;   ---------+-----------------------
  34. ;   R0         | number to be converted
  35. ;   AR1         | pointer to table with constants
  36. ;
  37. ; REGISTERS USED AS INPUT: R0, AR1
  38. ; REGISTERS MODIFIED: R0
  39. ; REGISTER CONTAINING RESULT: R0
  40. ;
  41. ; NOTE: Since the stack pointer SP is used, make sure to initialize it 
  42. ;    in the calling program.
  43. ;
  44. ;
  45. ;    CYCLES: 14 (worst case)     WORDS: 15
  46. ;=============================================================================
  47.     .global     TOIEEE
  48. ;
  49. TOIEEE    LDF    R0,R0        ; Determine the sign of the number
  50.     LDFZ    *+AR1(4),R0    ; If zero, load appropriate number
  51.     BND    NEG        ; Branch to NEG if negative (delayed)
  52.     ABSF    R0        ; Take the absolute value of the number
  53.     LSH    1,R0        ; Eliminate the sign bit in R0
  54.     PUSHF    R0
  55.     POP    R0        ; Place number in lower 32 bits of R0
  56.     ADDI    *+AR1(2),R0    ; Add exponent bias (127)
  57.     LSH    -1,R0        ; Add the positive sign
  58.     RETS
  59.  
  60.  
  61. NEG    POP    R0        ; Place number in lower 32 bits of R0
  62.     ADDI    *+AR1(2),R0    ; Add exponent bias (127)
  63.     LSH    -1,R0        ; Make space for the sign
  64.     ADDI    *+AR1(3),R0    ; Add the negative sign
  65.     RETS
  66.           
  67.