Subversion Repositories Kolibri OS

Rev

Go to most recent revision | 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. ;========================================================================
  37. ;==     Name:           I8S                                            ==
  38. ;==     Operation:      integer eight byte shift                       ==
  39. ;==     Inputs:         EDX;EAX   integer M1                           ==
  40. ;==                     ECX;EBX   integer M2  (ECX contents ignored)   ==
  41. ;==     Outputs:        EDX;EAX   product                              ==
  42. ;==     Volatile:       ECX, EBX destroyed                             ==
  43. ;========================================================================
  44. ; Special Note:
  45. ; If ECX ever takes on a meaningful use (i.e., is no longer ignored)
  46. ; then several routines that call these shift routines will require fixing.
  47. ; At present, the following routines ignore what is in ECX.
  48.  
  49.  
  50.         modstart        i8s
  51.  
  52.         xdefp   __U8RS
  53.  
  54.         defpe   __U8RS
  55.  
  56.         mov     ecx,ebx         ; get shift-count into cl
  57.         and     cl,03fH         ; get mod 64 shift count
  58.         test    cl,020H         ; see if count >= 32
  59.         jnz     L1
  60.         shrd    eax,edx,cl
  61.         shr     edx,cl
  62.         ret                     ; and return!!!
  63.  
  64. L1:
  65.         mov     eax,edx
  66.         sub     ecx,020H        ; knock off 32-bits of shifting
  67.         xor     edx,edx         ; zero extend result
  68.         shr     eax,cl
  69.         ret
  70.  
  71.         endproc __U8RS
  72.  
  73.         xdefp   __I8RS
  74.  
  75.         defpe   __I8RS
  76.  
  77.         mov     ecx,ebx         ; get shift-count into cl
  78.         and     cl,03fH         ; get mod 64 shift count
  79.         test    cl,020H         ; see if count >= 32
  80.         jnz     L2
  81.         shrd    eax,edx,cl
  82.         sar     edx,cl
  83.         ret                     ; and return!!!
  84.  
  85. L2:
  86.         mov     eax,edx         ; shift hi into lo (1st 32 bits now shifted)
  87.         sub     cl,020H         ; knock off 32-bits of shifting
  88.         sar     edx,31          ; sign extend hi-word
  89.         sar     eax,cl          ; shift remaining part
  90.         ret
  91.  
  92.         endproc __I8RS
  93.  
  94.         xdefp   __I8LS
  95.         xdefp   __U8LS
  96.  
  97.         defpe   __I8LS
  98.         defpe   __U8LS
  99.  
  100.         mov     ecx,ebx         ; get shift-count into cl
  101.         and     cl,03fH         ; get mod 64 shift count
  102.         test    cl,020H         ; see if count >= 32
  103.         jnz     L3
  104.         shld    edx,eax,cl
  105.         shl     eax,cl
  106.         ret                     ; and return!!!
  107.  
  108. L3:
  109.         mov     edx,eax         ; shift lo into hi (1st 32 bits now shifted)
  110.         sub     cl,020H         ; knock off 32-bits of shifting
  111.         xor     eax,eax         ; lo 32 bits are now zero
  112.         shl     edx,cl          ; shift remaining part
  113.         ret                     ; and return!!!
  114.  
  115.         endproc __U8LS
  116.         endproc __I8LS
  117.         endmod
  118.         end
  119.