FreeBSD/sys/contrib/x86emu/x86emu.c
/*
 * REMARKS:
 * Implements the ROR instruction and side effects.
 */
Implements the ROR instruction and side effects.
Implements the ROR instruction and side effects .
static uint8_t 
ror_byte(struct x86emu *emu, uint8_t d, uint8_t s)
{
	unsigned int res, cnt, mask;
	res = d;
	if ((cnt = s % 8) != 0) {	
		res = (d << (8 - cnt));
		mask = (1 << (8 - cnt)) - 1;
		res |= (d >> (cnt)) & mask;
		CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 6), F_OF);
	}
	if (s != 0) {
		CONDITIONAL_SET_FLAG(res & 0x80, F_CF);
	}
	return (uint8_t) res;
}
static uint8_t ror_byte ( struct x86emu * emu , uint8_t d , uint8_t s ) { unsigned int res , cnt , mask ; res = d ; if ( ( cnt = s % 8 ) != 0 ) { res = ( d << ( 8 - cnt ) ) ; mask = ( 1 << ( 8 - cnt ) ) - 1 ; res |= ( d >> ( cnt ) ) & mask ; CONDITIONAL_SET_FLAG ( s == 1 && XOR2 ( res >> 6 ) , F_OF ) ; } if ( s != 0 ) { CONDITIONAL_SET_FLAG ( res & 0x80 , F_CF ) ; } return ( uint8_t ) res ; }
REMARKS:
 Implements the ROR instruction and side effects.
REMARKS : Implements the ROR instruction and side effects .
/* rotate right */ /* s is the rotate distance.  It varies from 0 - 8. d is the byte
	 * object rotated.
	 * 
	 * have
	 * 
	 * B_7 ... B_0
	 * 
	 * The rotate is done mod 8.
	 * 
	 * IF n > 0 1) B_(8-(n+1)) .. B_(0)  <-  b_(7) .. b_(n) 2) B_(7) ..
	 * B_(8-n) <-  b_(n-1) .. b_(0) */ /* not a typo, do nada if cnt==0 */ /* B_(7) .. B_(8-n) <-  b_(n-1) .. b_(0) */ /* B_(8-(n+1)) .. B_(0)  <-  b_(7) .. b_(n) */ /* OVERFLOW is set *IFF* s==1, then it is the xor of the two
		 * most significant bits.  Blecck. */ /* set the new carry flag, Note that it is the high order bit
		 * of the result!!!                               */