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. ;<>
  35. ;<> __FDC - floating double comparison
  36. ;<>     input:  EDX:EAX - operand 1
  37. ;<>             ECX:EBX - operand 2
  38. ;<>       if op1 > op2,  1 is returned in EAX
  39. ;<>       if op1 < op2, -1 is returned in EAX
  40. ;<>       if op1 = op2,  0 is returned in EAX
  41. ;<>
  42. ;<>
  43. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  44. include mdef.inc
  45. include struct.inc
  46.  
  47.         modstart        fdc386
  48.  
  49.         xdefp   __FDC
  50.  
  51.         defpe   __FDC
  52.         push    EBP             ; save BP
  53.         test    EDX,07ff00000h  ; check for zero
  54.         _if     e               ; if it is then
  55.           sub   EDX,EDX         ; - make whole damn thing a zero
  56.         _endif                  ; endif
  57.         test    ECX,07ff00000h  ; check op2 for zero
  58.         _if     e               ; if it is then
  59.           sub   ECX,ECX         ; - make whole damn thing a zero
  60.         _endif                  ; endif
  61.         mov     EBP,ECX         ; save op2 exponent
  62.         xor     EBP,EDX         ; see about signs of the operands
  63.         mov     EBP,0           ; clear result
  64.         js      short cmpdone   ; quif arg1 & arg2 have diff signs
  65.         _guess                  ; guess
  66.           cmp   EDX,ECX         ; - compare high words of arg1, arg2
  67.           _quif ne              ; - quif not equal
  68.           cmp   EAX,EBX         ; - compare 2nd  words of arg1, arg2
  69.         _endguess               ; endguess
  70.         _if     ne              ; if arg1 <> arg2
  71.           rcr   ECX,1           ; - save carry in CX
  72.           xor   EDX,ECX         ; - sign of BX is sign of result
  73.  
  74. cmpdone:  _shl  EDX,1           ; - get sign of result into carry
  75.           sbb   EBP,0           ; - BP gets sign of result
  76.           _shl  EBP,1           ; - double BP
  77.           inc   EBP             ; - make BP -1 or 1
  78.         _endif                  ; endif
  79.         mov     EAX,EBP         ; get result
  80.         pop     EBP             ; restore BP
  81.         ret                     ; return to caller
  82.         endproc __FDC
  83.  
  84.         endmod
  85.         end
  86.