Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ;*
  3. ;*                            Open Watcom Project
  4. ;*
  5. ;*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
  6. ;*
  7. ;*  ========================================================================
  8. ;*
  9. ;*    This file contains Original Code and/or Modifications of Original
  10. ;*    Code as defined in and that are subject to the Sybase Open Watcom
  11. ;*    Public License version 1.0 (the 'License'). You may not use this file
  12. ;*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
  13. ;*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
  14. ;*    provided with the Original Code and Modifications, and is also
  15. ;*    available at www.sybase.com/developer/opensource.
  16. ;*
  17. ;*    The Original Code and all software distributed under the License are
  18. ;*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  19. ;*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
  20. ;*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
  21. ;*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
  22. ;*    NON-INFRINGEMENT. Please see the License for the specific language
  23. ;*    governing rights and limitations under the License.
  24. ;*
  25. ;*  ========================================================================
  26. ;*
  27. ;* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
  28. ;*               DESCRIBE IT HERE!
  29. ;*
  30. ;*****************************************************************************
  31.  
  32.  
  33. ;=========================================================================
  34. ;==     Name:           FSFD                                            ==
  35. ;==     Operation:      Float single to float double conversion         ==
  36. ;==     Inputs:         EAX     single precision float                  ==
  37. ;==     Outputs:        EDX:EAX         double precision float          ==
  38. ;==     Volatile:       none                                            ==
  39. ;=========================================================================
  40. include mdef.inc
  41. include struct.inc
  42.  
  43.         modstart        fsfd386
  44.  
  45.         xdefp   __FSFD
  46.  
  47.         defpe   __FSFD
  48.         _guess                   ; guess: number is 0.0 or -0.0
  49.           mov   EDX,EAX          ; - get float
  50.           and   EAX,7fffffffh    ; - remove sign
  51.           _quif ne               ; - quit if number is not +0.0 or -0.0
  52.         _admit                   ; guess: number is +-infinity
  53.           cmp   EAX,7f800000h    ; - quit if not +-infinity
  54.           _quif ne               ; - ...
  55.           or    EDX,7ff00000h    ; - set double precision infinity
  56.           sub   EAX,EAX          ; - ...
  57.         _admit                   ; admit: not a special number
  58.           test  EAX,7f800000h    ; - if exponent is 0 (denormal number)
  59.           _if   e                ; - then
  60.             or    EDX,7F800000h  ; - - set exponent to 0xFF
  61.             _loop                ; - - loop (normalize the fraction)
  62.               sub  EDX,00800000h ; - - - subtract 1 from exponent adjustment
  63.               _shl EAX,1         ; - - - shift fraction left
  64.               test EAX,00800000h ; - - - check to see if fraction is normalized
  65.             _until ne            ; - - until normalized
  66.             and   EDX,0FF800000h ; - - copy fraction back to EDX
  67.             and   EAX,007FFFFFh  ; - - ...
  68.             or    EDX,EAX        ; - - ...
  69.             sar   EDX,3          ; - shift over 3
  70.             and   EDX,8FFFFFFFh  ; - reset exponent extended bits
  71.             add   EDX,28200000h  ; - adjust exponent by (3FF - FF -7F + 1) shl 20  
  72.           _else                  ; - else
  73.             sar   EDX,3          ; - shift over 3
  74.             and   EDX,8FFFFFFFh  ; - reset exponent extended bits
  75.             cmp   EAX,7F800000h  ; - if number is not number (NaN)
  76.             _if   a              ;
  77.               or    EDX,7FF00000h; - adjust exponent to NaN 7FF shl 20
  78.             _else
  79.               add   EDX,38000000h; - adjust exponent by (3FF-7F) shl 20
  80.             _endif
  81.           _endif                ; - endif
  82.           and   EAX,7           ; - get bottom 3 bits of fraction
  83.           ror   EAX,3           ; - shift them to the top
  84.         _endguess               ; endguess
  85.         ret                     ; return
  86.         endproc __FSFD
  87.  
  88.         endmod
  89.         end
  90.