home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC.ZIP / LROTL.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.2 KB  |  49 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - lrotl.cas
  3.  *
  4.  * function(s)
  5.  *        _lrotl - rotates an unsigned long integer left
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma inline
  18. #include <asmrules.h>
  19. #include <stdlib.h>
  20.  
  21. /*-----------------------------------------------------------------------*
  22.  
  23. Name            _lrotl - rotates an unsigned long integer left
  24.  
  25. Usage           unsigned long _lrotl(unsigned long val, int rotate_count)
  26.  
  27. Prototype in    stdlib.h
  28.  
  29. Description     Rotates an unsigned long integer to the left count times.
  30.  
  31. Return value    The value after rotation.
  32.  
  33. *------------------------------------------------------------------------*/
  34. unsigned long _lrotl(unsigned long val, int rotate_count)
  35. {
  36. asm     mov     ax, W0(val)
  37. asm     mov     dx, W1(val)
  38. asm     mov     cx, rotate_count
  39. asm     and     cx, 01Fh
  40. asm     jz      Rotated
  41. Rotating:
  42. asm     rcl     ax, 1
  43. asm     rcl     dx, 1
  44. asm     adc     ax, 0
  45. asm     loop    Rotating
  46. Rotated:
  47.         return( MK_ULONG );
  48. }
  49.