FreeBSD/sys/contrib/x86emu/x86emu.c
/*
 * REMARKS:
 * Implements the SHR instruction and side effects.
 */
Implements the SHR instruction and side effects.
Implements the SHR instruction and side effects .
static uint32_t 
shr_long(struct x86emu *emu, uint32_t d, uint8_t s)
{
	unsigned int cnt, res, cf;
	if (s < 32) {
		cnt = s % 32;
		if (cnt > 0) {
			cf = d & (1 << (cnt - 1));
			res = d >> cnt;
			CONDITIONAL_SET_FLAG(cf, F_CF);
			CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
			CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
			CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
		} else {
			res = d;
		}
		if (cnt == 1) {
			CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF);
		} else {
			CLEAR_FLAG(F_OF);
		}
	} else {
		res = 0;
		CLEAR_FLAG(F_CF);
		CLEAR_FLAG(F_OF);
		SET_FLAG(F_ZF);
		CLEAR_FLAG(F_SF);
		CLEAR_FLAG(F_PF);
	}
	return res;
}
static uint32_t shr_long ( struct x86emu * emu , uint32_t d , uint8_t s ) { unsigned int cnt , res , cf ; if ( s < 32 ) { cnt = s % 32 ; if ( cnt > 0 ) { cf = d & ( 1 << ( cnt - 1 ) ) ; res = d >> cnt ; CONDITIONAL_SET_FLAG ( cf , F_CF ) ; CONDITIONAL_SET_FLAG ( ( res & 0xffffffff ) == 0 , F_ZF ) ; CONDITIONAL_SET_FLAG ( res & 0x80000000 , F_SF ) ; CONDITIONAL_SET_FLAG ( PARITY ( res & 0xff ) , F_PF ) ; } else { res = d ; } if ( cnt == 1 ) { CONDITIONAL_SET_FLAG ( XOR2 ( res >> 30 ) , F_OF ) ; } else { CLEAR_FLAG ( F_OF ) ; } } else { res = 0 ; CLEAR_FLAG ( F_CF ) ; CLEAR_FLAG ( F_OF ) ; SET_FLAG ( F_ZF ) ; CLEAR_FLAG ( F_SF ) ; CLEAR_FLAG ( F_PF ) ; } return res ; }
REMARKS:
 Implements the SHR instruction and side effects.
REMARKS : Implements the SHR instruction and side effects .