home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC.ZIP / H_LLSH.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-06-10  |  1.6 KB  |  51 lines

  1. ;[]-----------------------------------------------------------------[]
  2. ;|      H_LLSH.ASM -- long shift left                                |
  3. ;[]-----------------------------------------------------------------[]
  4.  
  5. ;
  6. ;       C/C++ Run Time Library - Version 5.0
  7. ;       Copyright (c) 1987, 1992 by Borland International
  8. ;       All Rights Reserved.
  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.