FreeBSD/sys/contrib/x86emu/x86emu.c
/*
 * REMARKS:
 * Implements the ROL instruction and side effects.
 */
Implements the ROL instruction and side effects.
Implements the ROL instruction and side effects .
static uint8_t 
rol_byte(struct x86emu *emu, uint8_t d, uint8_t s)
{
	unsigned int res, cnt, mask;
	res = d;
	if ((cnt = s % 8) != 0) {
		res = (d << cnt);
		mask = (1 << cnt) - 1;
		res |= (d >> (8 - cnt)) & mask;
		CONDITIONAL_SET_FLAG(s == 1 &&
		    XOR2((res & 0x1) + ((res >> 6) & 0x2)),
		    F_OF);
	}
	if (s != 0) {
		CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
	}
	return (uint8_t) res;
}
static uint8_t rol_byte ( struct x86emu * emu , uint8_t d , uint8_t s ) { unsigned int res , cnt , mask ; res = d ; if ( ( cnt = s % 8 ) != 0 ) { res = ( d << cnt ) ; mask = ( 1 << cnt ) - 1 ; res |= ( d >> ( 8 - cnt ) ) & mask ; CONDITIONAL_SET_FLAG ( s == 1 && XOR2 ( ( res & 0x1 ) + ( ( res >> 6 ) & 0x2 ) ) , F_OF ) ; } if ( s != 0 ) { CONDITIONAL_SET_FLAG ( res & 0x1 , F_CF ) ; } return ( uint8_t ) res ; }
REMARKS:
 Implements the ROL instruction and side effects.
REMARKS : Implements the ROL instruction and side effects .
/* rotate left */ /* s is the rotate distance.  It varies from 0 - 8. d is the byte
	 * object rotated.
	 * 
	 * have
	 * 
	 * CF  B_7 ... B_0
	 * 
	 * The new rotate is done mod 8. Much simpler than the "rcl" or "rcr"
	 * operations.
	 * 
	 * IF n > 0 1) B_(7) .. B_(n)  <-  b_(8-(n+1)) .. b_(0) 2) B_(n-1) ..
	 * B_(0) <-  b_(7) .. b_(8-n) */ /* B_(7) .. B_(n)  <-  b_(8-(n+1)) .. b_(0) */ /* B_(n-1) .. B_(0) <-  b_(7) .. b_(8-n) */ /* OVERFLOW is set *IFF* s==1, then it is the xor of CF and
		 * the most significant bit.  Blecck. */ /* set the new carry flag, Note that it is the low order bit
		 * of the result!!!                               */