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

  1. ;[]-----------------------------------------------------------------[]
  2. ;|      H_LLSH.ASM -- long shift left                                |
  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    LXLSH@
  15.     public    F_LXLSH@
  16.         public  N_LXLSH@
  17.  
  18. N_LXLSH@:
  19.         pop     bx                      ;fix up for far return
  20.         push    cs
  21.         push    bx
  22. LXLSH@:
  23. F_LXLSH@:
  24.     cmp    cl,16
  25.     jae    lsh@small
  26.     mov    bx,ax            ; save the low bits
  27.     shl    ax,cl            ; now shift each half
  28.     shl    dx,cl
  29. ;
  30. ;            We now have a hole in DX where the upper bits of
  31. ;            AX should have been shifted.  So we must take our
  32. ;            copy of AX and do a reverse shift to get the proper
  33. ;            bits to be or'ed into DX.
  34. ;
  35.     neg    cl
  36.     add    cl,16
  37.     shr    bx,cl
  38.     or    dx,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    ax,ax            ; We have now done a shift by 16.
  45.         shl     dx,cl                   ; Now shift the remainder.
  46.         retf
  47. _TEXT    ends
  48.     end
  49.