home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / _extends.cpp < prev    next >
Text File  |  1993-06-17  |  3KB  |  133 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.3, michal 05-93 :
  18. | code cleanup
  19. |
  20. | Revision 1.2, kub 01-90 :
  21. | added support for denormalized numbers
  22. |
  23. | Revision 1.1, kub 12-89 :
  24. | Ported over to 68k assembler
  25. |
  26. | Revision 1.0:
  27. | original 8088 code from P.S.Housel
  28.  
  29. BIAS4    =    0x7F-1
  30. BIAS8    =    0x3FF-1
  31.  
  32.     movel   sp@(4),d0    | get number
  33.     moveml    d2-d7,sp@-    | save regs to keep norm_df happy
  34.     moveq    #0,d5        | prepare double mantissa
  35.  
  36.     movel    d0,d4
  37.     swap    d0        | extract exponent
  38.     movew    d0,d2        | extract sign
  39.     bclr    #15,d0        | kill sign bit (exponent is 8 bits)
  40.     lsrw    #7,d0
  41.     andl    #0x7fffff,d4    | remove exponent from mantissa
  42.  
  43.     moveql    #-1,d1
  44.     cmpb    d1,d0
  45.     bne    nospec
  46.     tstl    d4
  47.     beq    retinf
  48. | ret nan
  49.     movel    d1,d0
  50.     lsrl    #1,d0        | #0x7fffffff -> d0
  51.     bra    return
  52. retinf:    movel    d4,d1        | 0 -> d1
  53.     movel    #0xffe00000,d0
  54.     lslw    #1,d2        | get extension bit
  55.     roxrl    #1,d0        | shift in sign bit
  56. return:    moveml    sp@+,d2-d7
  57.     rts
  58.  
  59. nospec: bset    #23,d4        | restore implied leading "1"
  60.     tstw    d0        | check for zero exponent - no leading "1"
  61.     bne    1f        | for denormalized numbers
  62.     bclr    #23,d4        | so clear it and ...
  63.     addw    #1,d0        | "normalize" exponent
  64. 1:
  65.     addw    #BIAS8-BIAS4-3,d0    | adjust bias, account for shift
  66.     clrw    d1        | dummy rounding info
  67.  
  68.     jmp    norm_df
  69.  
  70. # else    sfp004
  71.  
  72. | single precision floating point stuff for Atari-gcc using the SFP004
  73. | developed with gas
  74. |
  75. | single float to double float conversion routine
  76. |
  77. | M. Ritzert (mjr at dmzrzu71)
  78. |
  79. | 4.10.1990
  80. |
  81. | no NAN checking implemented since the 68881 treats this situation "correct",
  82. | i.e. according to IEEE
  83.  
  84. | addresses of the 68881 data port. This choice is fastest when much data is
  85. | transferred between the two processors.
  86.  
  87. comm =     -6
  88. resp =    -16
  89. zahl =      0
  90.  
  91. | waiting loop ...
  92. |
  93. | wait:
  94. | ww:    cmpiw    #0x8900,a1@(resp)
  95. |     beq    ww
  96. | is coded directly by
  97. |    .long    0x0c688900, 0xfff067f8
  98.  
  99.     lea    0xfffffa50:w,a0
  100.     movew    #0x4400,a0@(comm)    | load argument to fp0
  101.     cmpiw    #0x8900,a0@(resp)    | check
  102.     movel    sp@(4),a0@        | now push arg
  103.     movew    #0x7400,a0@(comm)    | result to d0/d1
  104.     .long    0x0c688900, 0xfff067f8
  105.     movel    a0@,d0            | pop double float
  106.     movel    a0@,d1
  107.     rts
  108.  
  109. # endif    sfp004
  110. #else    __M68881__
  111.  
  112. | mjr:    provided for safety. should be never called.
  113. |
  114. | single precision floating point stuff for Atari-gcc
  115. | developed with gas
  116. |
  117. | single float to double float conversion routine
  118. |
  119. | M. Ritzert (mjr at dfg.dbp.de)
  120. |
  121. | 4.10.1990
  122. | 11.11.1991
  123. |
  124. | no NAN checking implemented since the 68881 treats this situation "correct",
  125. | i.e. according to IEEE
  126.  
  127.     fmoves    sp@(4),fp0    | load argument to fp0
  128.     fmoved    fp0,sp@-    | read back as double
  129.     moveml    sp@+,d0-d1
  130.     rts
  131.  
  132. #endif    __M68881__
  133.