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. ;                               of AX:DX
  34. ;
  35. include mdef.inc
  36. include struct.inc
  37. include fstatus.inc
  38.  
  39.         modstart        fstat386
  40.  
  41.         xref    "C",__set_ERANGE
  42.         xref    __FPE_exception_
  43.  
  44.         datasegment
  45.         enddata
  46.         assume  ss:nothing
  47.  
  48.  
  49. FPS_OK                  =       0
  50. FPS_UNDERFLOW           =       1
  51. FPS_OVERFLOW            =       2
  52. FPS_DIVIDE_BY_0         =       3
  53. FPS_BAD_ARG             =       4
  54.  
  55. jmps    macro   dsym
  56.         jmp     short dsym
  57.         endm
  58.  
  59.  
  60.         xdefp   F8UnderFlow
  61.         xdefp   F4UnderFlow
  62.         xdefp   F8InvalidOp
  63.         xdefp   F8DivZero
  64.         xdefp   F4DivZero
  65.         xdefp   F8OverFlow
  66.         xdefp   F4OverFlow
  67.         xdefp   F8RetInf_
  68.         xdefp   _F8RetInf_
  69.  
  70.         defpe   F8UnderFlow
  71.         sub     EDX,EDX         ; . . .
  72.  
  73.         defpe   F4UnderFlow
  74. ;;      mov     EAX,FPE_UNDERFLOW; indicate underflow
  75. ;;      call    __FPE_exception_;
  76.         sub     EAX,EAX         ; return a zero
  77.         ret                     ; return
  78.         endproc F4UnderFlow
  79.         endproc F8UnderFlow
  80.  
  81.  
  82.         defpe   F8InvalidOp
  83.         mov     EAX,FPE_ZERODIVIDE; indicate divide by 0
  84.         call    __FPE_exception_;
  85.         jmps    F8RetInf9       ; return infinity
  86.         endproc F8InvalidOp
  87.  
  88.         defpe   F8DivZero
  89.         mov     EAX,FPE_ZERODIVIDE; indicate divide by 0
  90.         call    __FPE_exception_;
  91.         jmps    F8RetInf9       ; return infinity
  92.         endproc F8DivZero
  93.  
  94.         defpe   F8OverFlow
  95. ;
  96. ;       F8RetInf( sign : int ) : reallong
  97. ;
  98.         defpe   F8RetInf_
  99.         defpe   _F8RetInf_
  100.         push    EAX             ; save sign of result
  101.         call    __set_ERANGE    ; errno = ERANGE
  102.         mov     EAX,FPE_OVERFLOW ; indicate overflow
  103.         call    __FPE_exception_;
  104.         pop     EAX             ; restore sign of result
  105. F8RetInf9: and  EAX,80000000h   ; get sign
  106.         or      EAX,7FF00000h   ; set infinity
  107.         mov     EDX,EAX         ;
  108.         sub     EAX,EAX         ; ...
  109.         ret                     ; return
  110.         endproc _F8RetInf_
  111.         endproc F8RetInf_
  112.         endproc F8OverFlow
  113.  
  114.  
  115.         defpe   F4DivZero
  116.         mov     EAX,FPE_ZERODIVIDE; indicate divide by 0
  117.         call    __FPE_exception_;
  118.         jmps    F4RetInf9       ; return infinity
  119.         endproc F4DivZero
  120.  
  121.         defpe   F4OverFlow
  122.         defp    F4RetInf        ; return infinity
  123.         push    EAX             ; save sign of result
  124.         call    __set_ERANGE    ; errno = ERANGE
  125.         mov     EAX,FPE_OVERFLOW ; indicate overflow
  126.         call    __FPE_exception_;
  127.         pop     EAX             ; restore sign of result
  128. F4RetInf9: and  EAX,80000000h   ; get sign
  129.         or      EAX,7F800000h
  130.         ret
  131.         endproc F4RetInf
  132.         endproc F4OverFlow
  133.  
  134.  
  135.         endmod
  136.         end
  137.