FreeBSD/sys/contrib/x86emu/x86emu.c
/*
 * REMARKS:
 * Implements the OUT string instruction and side effects.
 */
Implements the OUT string instruction and side effects.
Implements the OUT string instruction and side effects .
static void 
outs(struct x86emu *emu, int size)
{
	int inc = size;
	if (ACCESS_FLAG(F_DF)) {
		inc = -size;
	}
	if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
		uint32_t count = ((emu->x86.mode & SYSMODE_PREFIX_DATA) ?
		    emu->x86.R_ECX : emu->x86.R_CX);
		switch (size) {
		case 1:
			while (count--) {
				(*emu->emu_outb) (emu, emu->x86.R_DX,
				    fetch_byte(emu, emu->x86.R_ES,
				    emu->x86.R_SI));
				emu->x86.R_SI += inc;
			}
			break;
		case 2:
			while (count--) {
				(*emu->emu_outw) (emu, emu->x86.R_DX,
				    fetch_word(emu, emu->x86.R_ES,
				    emu->x86.R_SI));
				emu->x86.R_SI += inc;
			}
			break;
		case 4:
			while (count--) {
				(*emu->emu_outl) (emu, emu->x86.R_DX,
				    fetch_long(emu, emu->x86.R_ES,
				    emu->x86.R_SI));
				emu->x86.R_SI += inc;
				break;
			}
		}
		emu->x86.R_CX = 0;
		if (emu->x86.mode & SYSMODE_PREFIX_DATA) {
			emu->x86.R_ECX = 0;
		}
		emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
	} else {
		switch (size) {
		case 1:
			(*emu->emu_outb) (emu, emu->x86.R_DX,
			    fetch_byte(emu, emu->x86.R_ES, emu->x86.R_SI));
			break;
		case 2:
			(*emu->emu_outw) (emu, emu->x86.R_DX,
			    fetch_word(emu, emu->x86.R_ES, emu->x86.R_SI));
			break;
		case 4:
			(*emu->emu_outl) (emu, emu->x86.R_DX,
			    fetch_long(emu, emu->x86.R_ES, emu->x86.R_SI));
			break;
		}
		emu->x86.R_SI += inc;
	}
}
static void outs ( struct x86emu * emu , int size ) { int inc = size ; if ( ACCESS_FLAG ( F_DF ) ) { inc = - size ; } if ( emu -> x86 . mode & ( SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE ) ) { uint32_t count = ( ( emu -> x86 . mode & SYSMODE_PREFIX_DATA ) ? emu -> x86 . R_ECX : emu -> x86 . R_CX ) ; switch ( size ) { case 1 : while ( count -- ) { ( * emu -> emu_outb ) ( emu , emu -> x86 . R_DX , fetch_byte ( emu , emu -> x86 . R_ES , emu -> x86 . R_SI ) ) ; emu -> x86 . R_SI += inc ; } break ; case 2 : while ( count -- ) { ( * emu -> emu_outw ) ( emu , emu -> x86 . R_DX , fetch_word ( emu , emu -> x86 . R_ES , emu -> x86 . R_SI ) ) ; emu -> x86 . R_SI += inc ; } break ; case 4 : while ( count -- ) { ( * emu -> emu_outl ) ( emu , emu -> x86 . R_DX , fetch_long ( emu , emu -> x86 . R_ES , emu -> x86 . R_SI ) ) ; emu -> x86 . R_SI += inc ; break ; } } emu -> x86 . R_CX = 0 ; if ( emu -> x86 . mode & SYSMODE_PREFIX_DATA ) { emu -> x86 . R_ECX = 0 ; } emu -> x86 . mode &= ~ ( SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE ) ; } else { switch ( size ) { case 1 : ( * emu -> emu_outb ) ( emu , emu -> x86 . R_DX , fetch_byte ( emu , emu -> x86 . R_ES , emu -> x86 . R_SI ) ) ; break ; case 2 : ( * emu -> emu_outw ) ( emu , emu -> x86 . R_DX , fetch_word ( emu , emu -> x86 . R_ES , emu -> x86 . R_SI ) ) ; break ; case 4 : ( * emu -> emu_outl ) ( emu , emu -> x86 . R_DX , fetch_long ( emu , emu -> x86 . R_ES , emu -> x86 . R_SI ) ) ; break ; } emu -> x86 . R_SI += inc ; } }
REMARKS:
 Implements the OUT string instruction and side effects.
REMARKS : Implements the OUT string instruction and side effects .
/* dont care whether REPE or REPNE */ /* out until CX is ZERO. */