FreeBSD/sys/contrib/x86emu/x86emu.c
/*
 * REMARKS:
 * Implements the SHL instruction and side effects.
 */
Implements the SHL instruction and side effects.
Implements the SHL instruction and side effects .
static uint32_t 
shl_long(struct x86emu *emu, uint32_t d, uint8_t s)
{
	unsigned int cnt, res, cf;
	if (s < 32) {
		cnt = s % 32;
		if (cnt > 0) {
			res = d << cnt;
			cf = d & (1 << (32 - 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((((res & 0x80000000) == 0x80000000)
			    ^ (ACCESS_FLAG(F_CF) != 0)), F_OF);
		} else {
			CLEAR_FLAG(F_OF);
		}
	} else {
		res = 0;
		CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x80000000, F_CF);
		CLEAR_FLAG(F_OF);
		CLEAR_FLAG(F_SF);
		SET_FLAG(F_PF);
		SET_FLAG(F_ZF);
	}
	return res;
}
static uint32_t shl_long ( struct x86emu * emu , uint32_t d , uint8_t s ) { unsigned int cnt , res , cf ; if ( s < 32 ) { cnt = s % 32 ; if ( cnt > 0 ) { res = d << cnt ; cf = d & ( 1 << ( 32 - 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 ( ( ( ( res & 0x80000000 ) == 0x80000000 ) ^ ( ACCESS_FLAG ( F_CF ) != 0 ) ) , F_OF ) ; } else { CLEAR_FLAG ( F_OF ) ; } } else { res = 0 ; CONDITIONAL_SET_FLAG ( ( d << ( s - 1 ) ) & 0x80000000 , F_CF ) ; CLEAR_FLAG ( F_OF ) ; CLEAR_FLAG ( F_SF ) ; SET_FLAG ( F_PF ) ; SET_FLAG ( F_ZF ) ; } return res ; }
REMARKS:
 Implements the SHL instruction and side effects.
REMARKS : Implements the SHL instruction and side effects .