FreeBSD/sys/contrib/x86emu/x86emu.c
/*
 * REMARKS:
 * Implements the DIV instruction and side effects.
 */
Implements the DIV instruction and side effects.
Implements the DIV instruction and side effects .
static void 
div_word(struct x86emu *emu, uint16_t s)
{
	uint32_t dvd, div, mod;
	dvd = (((uint32_t) emu->x86.R_DX) << 16) | emu->x86.R_AX;
	if (s == 0) {
		x86emu_intr_raise(emu, 8);
		return;
	}
	div = dvd / (uint16_t) s;
	mod = dvd % (uint16_t) s;
	if (div > 0xffff) {
		x86emu_intr_raise(emu, 8);
		return;
	}
	CLEAR_FLAG(F_CF);
	CLEAR_FLAG(F_SF);
	CONDITIONAL_SET_FLAG(div == 0, F_ZF);
	CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
	emu->x86.R_AX = (uint16_t) div;
	emu->x86.R_DX = (uint16_t) mod;
}
static void div_word ( struct x86emu * emu , uint16_t s ) { uint32_t dvd , div , mod ; dvd = ( ( ( uint32_t ) emu -> x86 . R_DX ) << 16 ) | emu -> x86 . R_AX ; if ( s == 0 ) { x86emu_intr_raise ( emu , 8 ) ; return ; } div = dvd / ( uint16_t ) s ; mod = dvd % ( uint16_t ) s ; if ( div > 0xffff ) { x86emu_intr_raise ( emu , 8 ) ; return ; } CLEAR_FLAG ( F_CF ) ; CLEAR_FLAG ( F_SF ) ; CONDITIONAL_SET_FLAG ( div == 0 , F_ZF ) ; CONDITIONAL_SET_FLAG ( PARITY ( mod & 0xff ) , F_PF ) ; emu -> x86 . R_AX = ( uint16_t ) div ; emu -> x86 . R_DX = ( uint16_t ) mod ; }
REMARKS:
 Implements the DIV instruction and side effects.
REMARKS : Implements the DIV instruction and side effects .