else
{
USHORT Source, Destination, Result;
+ ULONG DoubleSource;
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Source, &Destination))
{
return FALSE;
}
+ DoubleSource = Source | (Source << 16);
+
/* Calculate the result */
- Result = (Destination << Count) | (Source >> (16 - Count));
+ Result = (Destination << Count) | (DoubleSource >> (32 - Count));
/* Update flags */
State->Flags.Cf = (Destination >> (16 - Count)) & 1;
/* Calculate the result */
Result = (Destination >> Count) | (Source << (16 - Count));
+ if (Count >= 16) Result |= (ULONG)(Source | (Source << 16)) >> (Count - 16);
+
/* Update flags */
State->Flags.Cf = (Result >> (Count - 1)) & 1;
if (Count == 1) State->Flags.Of = (Result & SIGN_FLAG_WORD)
}
}
- /* Clear ZF */
- State->Flags.Zf = FALSE;
+ /* Set ZF */
+ State->Flags.Zf = (Value == 0);
+ if (State->Flags.Zf) return TRUE;
for (i = 0; i < DataSize; i++)
{
if(Value & (1 << i))
{
- /* Set ZF */
- State->Flags.Zf = TRUE;
-
/* Save the bit number */
BitNumber = i;
}
}
- if (State->Flags.Zf)
+ /* Write back the result */
+ if (OperandSize)
{
- /* Write back the result */
- if (OperandSize)
+ if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber))
{
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber))
- {
- /* Exception occurred */
- return FALSE;
- }
+ /* Exception occurred */
+ return FALSE;
}
- else
+ }
+ else
+ {
+ if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber)))
{
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber)))
- {
- /* Exception occurred */
- return FALSE;
- }
+ /* Exception occurred */
+ return FALSE;
}
}
}
}
- /* Clear ZF */
- State->Flags.Zf = FALSE;
+ /* Set ZF according to the value */
+ State->Flags.Zf = (Value == 0);
+ if (State->Flags.Zf) return TRUE;
for (i = DataSize - 1; i >= 0; i--)
{
if(Value & (1 << i))
{
- /* Set ZF */
- State->Flags.Zf = TRUE;
-
/* Save the bit number */
BitNumber = i;
}
}
- if (State->Flags.Zf)
+ /* Write back the result */
+ if (OperandSize)
{
- /* Write back the result */
- if (OperandSize)
+ if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber))
{
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber))
- {
- /* Exception occurred */
- return FALSE;
- }
+ /* Exception occurred */
+ return FALSE;
}
- else
+ }
+ else
+ {
+ if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber)))
{
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber)))
- {
- /* Exception occurred */
- return FALSE;
- }
+ /* Exception occurred */
+ return FALSE;
}
}