mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[FAST486]
Fix the BSF and BSR instructions. Partially fix SHLD and SHRD. svn path=/branches/ntvdm/; revision=60987
This commit is contained in:
parent
a3513c8f18
commit
cdf876ead9
1 changed files with 34 additions and 39 deletions
|
@ -669,6 +669,7 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeShld)
|
|||
else
|
||||
{
|
||||
USHORT Source, Destination, Result;
|
||||
ULONG DoubleSource;
|
||||
|
||||
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Source, &Destination))
|
||||
{
|
||||
|
@ -676,8 +677,10 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeShld)
|
|||
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;
|
||||
|
@ -881,6 +884,8 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeShrd)
|
|||
/* 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)
|
||||
|
@ -1535,16 +1540,14 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsf)
|
|||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
|
@ -1553,8 +1556,6 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsf)
|
|||
}
|
||||
}
|
||||
|
||||
if (State->Flags.Zf)
|
||||
{
|
||||
/* Write back the result */
|
||||
if (OperandSize)
|
||||
{
|
||||
|
@ -1572,7 +1573,6 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsf)
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1625,16 +1625,14 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsr)
|
|||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
|
@ -1643,8 +1641,6 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsr)
|
|||
}
|
||||
}
|
||||
|
||||
if (State->Flags.Zf)
|
||||
{
|
||||
/* Write back the result */
|
||||
if (OperandSize)
|
||||
{
|
||||
|
@ -1662,7 +1658,6 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsr)
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue