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

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