FreeBSD/sys/contrib/x86emu/x86emu.c
/*
 * REMARKS:
 * Implements the IDIV instruction and side effects.
 */
Implements the IDIV instruction and side effects.
Implements the IDIV instruction and side effects .
static void 
idiv_long(struct x86emu *emu, uint32_t s)
{
	int64_t dvd, div, mod;
	dvd = (((int64_t) emu->x86.R_EDX) << 32) | emu->x86.R_EAX;
	if (s == 0) {
		x86emu_intr_raise(emu, 8);
		return;
	}
	div = dvd / (int32_t) s;
	mod = dvd % (int32_t) s;
	if (div > 0x7fffffff || div < -0x7fffffff) {
		x86emu_intr_raise(emu, 8);
		return;
	}
	CLEAR_FLAG(F_CF);
	CLEAR_FLAG(F_AF);
	CLEAR_FLAG(F_SF);
	SET_FLAG(F_ZF);
	CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
	emu->x86.R_EAX = (uint32_t) div;
	emu->x86.R_EDX = (uint32_t) mod;
}
static void idiv_long ( struct x86emu * emu , uint32_t s ) { int64_t dvd , div , mod ; dvd = ( ( ( int64_t ) emu -> x86 . R_EDX ) << 32 ) | emu -> x86 . R_EAX ; if ( s == 0 ) { x86emu_intr_raise ( emu , 8 ) ; return ; } div = dvd / ( int32_t ) s ; mod = dvd % ( int32_t ) s ; if ( div > 0x7fffffff || div < -0x7fffffff ) { x86emu_intr_raise ( emu , 8 ) ; return ; } CLEAR_FLAG ( F_CF ) ; CLEAR_FLAG ( F_AF ) ; CLEAR_FLAG ( F_SF ) ; SET_FLAG ( F_ZF ) ; CONDITIONAL_SET_FLAG ( PARITY ( mod & 0xff ) , F_PF ) ; emu -> x86 . R_EAX = ( uint32_t ) div ; emu -> x86 . R_EDX = ( uint32_t ) mod ; }
REMARKS:
 Implements the IDIV instruction and side effects.
REMARKS : Implements the IDIV instruction and side effects .