home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / libsrc87 / _extends.cpp < prev    next >
Encoding:
Text File  |  1993-07-30  |  2.7 KB  |  131 lines

  1. |
  2. | single float to double float conversion routine
  3. |
  4.     .text
  5.     .even
  6.     .globl    __extendsfdf2, ___extendsfdf2
  7.  
  8. __extendsfdf2:
  9. ___extendsfdf2:
  10.  
  11. #ifndef    __M68881__
  12. # ifndef sfp004
  13. |
  14. | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  15. | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  16. |
  17. | Revision 1.2, kub 01-90 :
  18. | added support for denormalized numbers
  19. |
  20. | Revision 1.1, kub 12-89 :
  21. | Ported over to 68k assembler
  22. |
  23. | Revision 1.0:
  24. | original 8088 code from P.S.Housel
  25.  
  26. BIAS4    =    0x7F-1
  27. BIAS8    =    0x3FF-1
  28.  
  29.     lea    sp@(4),a0    | parameter pointer
  30.     moveml    d2-d7,sp@-    | save regs to keep norm_df happy
  31.     movel    a0@,d4        | get number
  32.     clrl    d5        | prepare double mantissa
  33.  
  34.     movew    a0@,d0        | extract exponent
  35.     movew    d0,d2        | extract sign
  36.     lsrw    #7,d0
  37.     andw    #0xff,d0    | kill sign bit (exponent is 8 bits)
  38.     andl    #0x7fffff,d4    | remove exponent from mantissa
  39.  
  40.     cmpb    #0xff,d0
  41.     bne    nospec
  42.     tstl    d4
  43.     beq    retinf
  44. | ret nan
  45.     movel    #0x7fffffff,d0
  46.     moveql    #-1,d1
  47. return:    moveml    sp@+,d2-d7
  48.     rts
  49. retinf:    clrl    d1
  50.     movel    #0x7ff00000,d0
  51.     tstw    d2
  52.     bpl    return
  53.     bset    #31,d0
  54.     bra    return
  55.  
  56.     
  57. nospec:    tstw    d0        | check for zero exponent - no leading "1"
  58.     beq    0f        | for denormalized numbers
  59.     orl    #0x800000,d4    | restore implied leading "1"
  60.     bra    1f
  61. 0:    addw    #1,d0        | "normalize" exponent
  62. 1:
  63.     addw    #BIAS8-BIAS4-3,d0    | adjust bias, account for shift
  64.     clrw    d1        | dummy rounding info
  65.  
  66.     jmp    norm_df
  67.  
  68. # else    sfp004
  69.  
  70. | single precision floating point stuff for Atari-gcc using the SFP004
  71. | developed with gas
  72. |
  73. | single float to double float conversion routine
  74. |
  75. | M. Ritzert (mjr at dmzrzu71)
  76. |
  77. | 4.10.1990
  78. |
  79. | no NAN checking implemented since the 68881 treats this situation "correct",
  80. | i.e. according to IEEE
  81.  
  82. | addresses of the 68881 data port. This choice is fastest when much data is
  83. | transferred between the two processors.
  84.  
  85. comm =     -6
  86. resp =    -16
  87. zahl =      0
  88.  
  89. | waiting loop ...
  90. |
  91. | wait:
  92. | ww:    cmpiw    #0x8900,a1@(resp)
  93. |     beq    ww
  94. | is coded directly by
  95. |    .long    0x0c688900, 0xfff067f8
  96.  
  97.     lea    0xfffffa50:w,a0
  98.     movew    #0x4400,a0@(comm)    | load argument to fp0
  99.     cmpiw    #0x8900,a0@(resp)    | check
  100.     movel    a7@(4),a0@        | now push arg
  101.     movew    #0x7400,a0@(comm)    | result to d0/d1
  102.     .long    0x0c688900, 0xfff067f8
  103.     movel    a0@,d0            | pop double float
  104.     movel    a0@,d1
  105.     rts
  106.  
  107. # endif    sfp004
  108. #else    __M68881__
  109.  
  110. | mjr:    provided for safety. should be never called.
  111. |
  112. | single precision floating point stuff for Atari-gcc
  113. | developed with gas
  114. |
  115. | single float to double float conversion routine
  116. |
  117. | M. Ritzert (mjr at dfg.dbp.de)
  118. |
  119. | 4.10.1990
  120. | 11.11.1991
  121. |
  122. | no NAN checking implemented since the 68881 treats this situation "correct",
  123. | i.e. according to IEEE
  124.  
  125.     fmoves    a7@(4),fp0    | load argument to fp0
  126.     fmoved    fp0,a7@-    | read back as double
  127.     moveml    a7@+,d0-d1
  128.     rts
  129.  
  130. #endif    __M68881__
  131.