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. include mdef.inc
  34. include struct.inc
  35.  
  36.                 modstart        msfs386
  37.  
  38.                 xdefp   "C",_fmsbintoieee
  39.                 defpe   _fmsbintoieee
  40.  
  41. ifdef __STACK__
  42.                 mov     eax,dword ptr +4H[esp]
  43.                 mov     edx,dword ptr +8H[esp]
  44. endif
  45.  
  46. ; At this point:
  47. ; eax     - ptr to MBF source float
  48. ; edx     - ptr to IEEE dest float
  49.  
  50.                 mov     eax,[eax]       ; load MBF float
  51.                                         ; MBF exponent = 0 ?
  52.                 test    eax,0ff000000h
  53.                 jne     MBFNonZero      ; yes, jump
  54.  
  55.                 xor     eax,eax         ; IEEE 0.0
  56.                 mov     [edx],eax       ; store IEEE float
  57.                 ret                     ; return 0 (no overflow)
  58.  
  59. ; At this point:
  60. ; eax     - MBF source float
  61. ; edx     - ptr to IEEE dest float
  62.  
  63. MBFNonZero:     rol     eax,9           ; rotate exponent for better analysis
  64.                 shr     eax,1           ; shift    out
  65.                 rcr     al,1            ; move sign bit
  66.                 adc     eax,eax         ; shift back
  67.                 sub     al,2            ; convert exponent
  68.                 jc      MBFExp1         ; jump if MBF exponent 1
  69.                 je      MBFExp2         ; jump if MBF exponent 2
  70.                 ror     eax,9           ; rotate so IEEE float
  71. IEEEStore:
  72.                 mov     [edx],eax       ; store IEEE float
  73.                 xor     eax,eax         ; return 0 (no overflow)
  74.                 ret                     ; :
  75.  
  76. MBFExp1:        and     al,1            ; zero exponent except implied 1
  77.                 ror     eax,9           ; rotate so IEEE float
  78.                 sar     eax,2           ; convert to IEEE denormal
  79.                 adc     eax,0           ; add in round bit
  80.                 and     eax,80FFFFFFh   ; zero surplus sign bits
  81.                 jmp     short IEEEStore ; continue
  82.  
  83. MBFExp2:        or      al,1            ; set implied 1
  84.                 ror     eax,9           ; rotate so IEEE float
  85.                 sar     eax,1           ; convert to IEEE denormal
  86.                 adc     eax,0           ; add in round bit
  87.                 and     eax,80FFFFFFh   ; zero surplus sign bit
  88.                 jmp     short IEEEStore ; continue
  89.  
  90.                 endproc _fmsbintoieee
  91.  
  92.                 endmod
  93.                 end
  94.