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:  Signed 4-byte division for 386.
  28. ;*
  29. ;*****************************************************************************
  30.  
  31.  
  32. ;========================================================================
  33. ;==     Name:           LDIV                                           ==
  34. ;==     Operation:      Signed 4 byte divide                           ==
  35. ;==     Inputs:         EAX     Dividend                               ==
  36. ;==                     EDX/ECX Divisor                                ==
  37. ;==                     SS:ESI  pointer to result structure            ==
  38. ;==     Volatile:       none                                           ==
  39. ;========================================================================
  40.  
  41. include mdef.inc
  42. include struct.inc
  43.  
  44. ifdef _PROFILE
  45. include p5prof.inc
  46. endif
  47.         modstart        ldiv386
  48.  
  49.         defpe   div
  50.         xdefp   "C",div
  51.         defpe   ldiv
  52.         xdefp   "C",ldiv
  53.     ifdef _PROFILE
  54.         P5Prolog
  55.     endif
  56.     ifdef __STACK__
  57.         mov     EAX,4[ESP]      ; get numerator
  58.         mov     ECX,8[ESP]      ; get divisor
  59.                                 ; we don't need to save/restore ECX
  60.     else
  61.         push    ECX             ; save ECX
  62.         mov     ECX,EDX         ; get divisor
  63.     endif
  64.         cdq                     ; sign extend dividend
  65.         idiv    ECX             ; do the divide
  66.         mov     [ESI],EAX       ; store quotient
  67.         mov     4[ESI],EDX      ; store remainder
  68.     ifndef __STACK__
  69.         pop     ECX             ; restore ECX
  70.     endif
  71.     ifdef _PROFILE
  72.         P5Epilog
  73.     endif
  74.         ret                     ; return
  75.         endproc ldiv
  76.         endproc div
  77.  
  78.         endmod
  79.         end
  80.