/* Normalize the count */
Count &= 0x1F;
- if (Operation <= 1) Count %= Bits;
- else if (Operation <= 3) Count %= Bits + 1;
+ if ((Operation == 2) || (Operation == 3)) Count %= Bits + 1;
/* If the count is zero, do nothing */
if (Count == 0) return Value;
/* ROL */
case 0:
{
+ Count %= Bits;
Result = (Value << Count) | (Value >> (Bits - Count));
/* Update CF and OF */
/* ROR */
case 1:
{
+ Count %= Bits;
Result = (Value >> Count) | (Value << (Bits - Count));
/* Update CF and OF */
TOGGLE_OPSIZE(OperandSize);
TOGGLE_ADSIZE(AddressSize);
- if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
+ /* Pop a value from the stack - this must be done first */
+ if (!Fast486StackPop(State, &Value))
{
/* Exception occurred */
return FALSE;
}
- if (ModRegRm.Register != 0)
+ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
- /* Invalid */
- Fast486Exception(State, FAST486_EXCEPTION_UD);
+ /* Exception occurred - restore SP */
+ if (OperandSize) State->GeneralRegs[FAST486_REG_ESP].Long -= sizeof(ULONG);
+ else State->GeneralRegs[FAST486_REG_ESP].LowWord -= sizeof(USHORT);
+
return FALSE;
}
- /* Pop a value from the stack */
- if (!Fast486StackPop(State, &Value))
+ if (ModRegRm.Register != 0)
{
- /* Exception occurred */
+ /* Invalid */
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
}
/* Normalize the bit number */
- BitNumber &= (1 << DataSize) - 1;
+ BitNumber %= DataSize;
if (OperandSize)
{