/* Bit manipulation routines for the Versaplot library */
/* Written by Gordon Hughes for Lattice Logic Limited  */
/* March 1986                                          */

iram_ (iword, kount, mask)
   int *iword, *kount, *mask;
{
   register int word, count;
   word = *iword;
   count = *kount;
/*    if (count != 0) {             */
/*       if (count > 0 ) {          */
/* NB: should be a rorl instruction */
/*           word = word >> count;  */
/*       } else {                   */
/*           count = - count;       */
/* NB: should be a roll instruction */
/*           word = word << count;  */
/*       }                          */
/*    }                             */
/* Assembly code assumes D7 has WORD */
/* Assembly code assumes D6 has COUNT */
   asm ("      tstl d6");
   asm ("      jeq  ML10");
   asm ("      jle  ML11");
   asm ("      rorl d6,d7");
   asm ("      jra  ML10");
   asm ("ML11:");
   asm ("      negl d6");
   asm ("      roll d6,d7");
   asm ("ML10:");
   return (word & *mask);
}
