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

  1. /*-----------------------------------------------------------------------*
  2.  * filename - lrotr.cas
  3.  *
  4.  * function(s)
  5.  *        _lrotr - rotates an unsigned long integer right
  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
  24.  
  25. Usage           unsigned long _lrotr(unsigned long val, int rotate_count)
  26.  
  27. Prototype in    stdlib.h
  28.  
  29. Description     Rotates an unsigned long integer to the right count times.
  30.  
  31. Return value    The value after rotation.
  32.  
  33. *------------------------------------------------------------------------*/
  34. unsigned long _lrotr(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     mov     bx, dx
  43. asm     shr     bx, 1
  44. asm     rcr     ax, 1
  45. asm     rcr     dx, 1
  46. asm     loop    Rotating
  47.  
  48. Rotated:
  49.         return( MK_ULONG );
  50. }
  51.