home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / H_LURSH.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-07  |  1.4 KB  |  50 lines

  1. ;[]-----------------------------------------------------------------[]
  2. ;|      H_LURSH.ASM -- long shift right                              |
  3. ;|                                                                   |
  4. ;|      Turbo-C Run Time Library        Version 3.0                  |
  5. ;|                                                                   |
  6. ;|      Copyright (c) 1987,1988,1990 by Borland International Inc.   |
  7. ;|      All Rights Reserved.                                         |
  8. ;[]-----------------------------------------------------------------[]
  9.  
  10.     INCLUDE    RULES.ASI
  11.  
  12. _TEXT    segment    public byte 'CODE'
  13.     assume    cs:_TEXT
  14.     public    LXURSH@
  15.         public  F_LXURSH@
  16.         public  N_LXURSH@
  17.  
  18. N_LXURSH@:
  19.         pop     bx                      ;fix up far return
  20.         push    cs
  21.         push    bx
  22. LXURSH@:
  23. F_LXURSH@:
  24.     cmp    cl,16
  25.     jae    lsh@small
  26.     mov    bx,dx            ; save the high bits
  27.     shr    ax,cl            ; now shift each half
  28.     shr    dx,cl
  29. ;
  30. ;            We now have a hole in AX where the lower bits of
  31. ;            DX should have been shifted.  So we must take our
  32. ;            copy of DX and do a reverse shift to get the proper
  33. ;            bits to be or'ed into AX.
  34. ;
  35.     neg    cl
  36.     add    cl,16
  37.     shl    bx,cl
  38.     or    ax,bx
  39.         retf
  40. lsh@small:
  41.     sub    cl,16            ; for shifts more than 15, do this
  42.                     ; short sequence.
  43.         xchg    ax,dx
  44.     xor    dx,dx            ; We have now done a shift by 16.
  45.     shr    ax,cl            ; Now shift the remainder.
  46.         retf
  47.  
  48. _TEXT    ends
  49.     end
  50.