{
ULONG Result;
ULONG SignFlag = 1 << (Bits - 1);
- ULONG MaxValue = (1 << Bits) - 1;
+ ULONG MaxValue = (SignFlag - 1) | SignFlag;
/* Make sure the values don't exceed the maximum for their size */
FirstValue &= MaxValue;
State->Flags.Cf = (Result < FirstValue) && (Result < SecondValue);
State->Flags.Of = ((FirstValue & SignFlag) == (SecondValue & SignFlag))
&& ((FirstValue & SignFlag) != (Result & SignFlag));
- State->Flags.Af = (((FirstValue & 0x0F) + (SecondValue & 0x0F)) & 0x10) ? TRUE : FALSE;
+ State->Flags.Af = ((((FirstValue & 0x0F) + (SecondValue & 0x0F)) & 0x10) != 0);
break;
}
|| ((Result < FirstValue) && (Result < (SecondValue + Carry)));
State->Flags.Of = ((FirstValue & SignFlag) == (SecondValue & SignFlag))
&& ((FirstValue & SignFlag) != (Result & SignFlag));
- State->Flags.Af = (((FirstValue & 0x0F) + ((SecondValue + Carry) & 0x0F)) & 0x10)
- ? TRUE : FALSE;
+ State->Flags.Af = ((((FirstValue & 0x0F) + ((SecondValue + Carry) & 0x0F)) & 0x10) != 0);
break;
}
Result = (FirstValue - SecondValue) & MaxValue;
/* Update CF, OF and AF */
- State->Flags.Cf = FirstValue < SecondValue;
+ State->Flags.Cf = (FirstValue < SecondValue);
State->Flags.Of = ((FirstValue & SignFlag) != (SecondValue & SignFlag))
&& ((FirstValue & SignFlag) != (Result & SignFlag));
State->Flags.Af = (FirstValue & 0x0F) < (SecondValue & 0x0F);
}
/* Update ZF, SF and PF */
- State->Flags.Zf = (Result == 0) ? TRUE : FALSE;
- State->Flags.Sf = (Result & SignFlag) ? TRUE : FALSE;
+ State->Flags.Zf = (Result == 0);
+ State->Flags.Sf = ((Result & SignFlag) != 0);
State->Flags.Pf = Fast486CalculateParity(LOBYTE(Result));
/* Return the result */
/* Update CF and OF */
State->Flags.Cf = Result & 1;
- if (Count == 1) State->Flags.Of = ((Result & HighestBit) ? TRUE : FALSE)
- ^ State->Flags.Cf;
+ if (Count == 1) State->Flags.Of = State->Flags.Cf
+ ^ ((Result & HighestBit) != 0);
break;
}
Result = (Value >> Count) | (Value << (Bits - Count));
/* Update CF and OF */
- State->Flags.Cf = (Result & HighestBit) ? TRUE : FALSE;
+ State->Flags.Cf = ((Result & HighestBit) != 0);
if (Count == 1) State->Flags.Of = State->Flags.Cf
- ^ ((Result & (HighestBit >> 1))
- ? TRUE : FALSE);
+ ^ ((Result & (HighestBit >> 1)) != 0);
break;
}
| (Value >> (Bits - Count + 1));
/* Update CF and OF */
- State->Flags.Cf = (Value & (1 << (Bits - Count))) ? TRUE : FALSE;
- if (Count == 1) State->Flags.Of = ((Result & HighestBit) ? TRUE : FALSE)
- ^ State->Flags.Cf;
+ State->Flags.Cf = ((Value & (1 << (Bits - Count))) != 0);
+ if (Count == 1) State->Flags.Of = State->Flags.Cf
+ ^ ((Result & HighestBit) != 0);
break;
}
| (Value << (Bits - Count + 1));
/* Update CF and OF */
- State->Flags.Cf = (Value & (1 << (Bits - Count))) ? TRUE : FALSE;
+ State->Flags.Cf = ((Value & (1 << (Bits - Count))) != 0);
if (Count == 1) State->Flags.Of = State->Flags.Cf
- ^ ((Result & (HighestBit >> 1))
- ? TRUE : FALSE);
+ ^ ((Result & (HighestBit >> 1)) != 0);
break;
}
Result = Value << Count;
/* Update CF and OF */
- State->Flags.Cf = (Value & (1 << (Bits - Count))) ? TRUE : FALSE;
- if (Count == 1) State->Flags.Of = ((Result & HighestBit) ? TRUE : FALSE)
- ^ (State->Flags.Cf ? TRUE : FALSE);
+ State->Flags.Cf = ((Value & (1 << (Bits - Count))) != 0);
+ if (Count == 1) State->Flags.Of = State->Flags.Cf
+ ^ ((Result & HighestBit) != 0);
break;
}
Result = Value >> Count;
/* Update CF and OF */
- State->Flags.Cf = (Value & (1 << (Count - 1))) ? TRUE : FALSE;
- if (Count == 1) State->Flags.Of = (Value & HighestBit) ? TRUE : FALSE;
+ State->Flags.Cf = ((Value & (1 << (Count - 1))) != 0);
+ if (Count == 1) State->Flags.Of = ((Value & HighestBit) != 0);
break;
}
if (Value & HighestBit) Result |= ((1 << Count) - 1) << (Bits - Count);
/* Update CF and OF */
- State->Flags.Cf = (Value & (1 << (Count - 1))) ? TRUE : FALSE;
+ State->Flags.Cf = ((Value & (1 << (Count - 1))) != 0);
if (Count == 1) State->Flags.Of = FALSE;
break;
}
}
- /* Update ZF, SF and PF */
- State->Flags.Zf = (Result == 0) ? TRUE : FALSE;
- State->Flags.Sf = (Result & HighestBit) ? TRUE : FALSE;
- State->Flags.Pf = Fast486CalculateParity(Result);
+ if (Operation >= 4)
+ {
+ /* Update ZF, SF and PF */
+ State->Flags.Zf = (Result == 0);
+ State->Flags.Sf = ((Result & HighestBit) != 0);
+ State->Flags.Pf = Fast486CalculateParity(Result);
+ }
/* Return the result */
return Result;
{
return Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Value);
}
-
+
return TRUE;
}
{
FAST486_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);
CHAR ImmByte;
FAST486_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);
ULONG Value;
FAST486_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);
UCHAR Count;
FAST486_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);
{
FAST486_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);
{
FAST486_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);
/* Update the flags */
State->Flags.Cf = FALSE;
State->Flags.Of = FALSE;
- State->Flags.Zf = (Result == 0) ? TRUE : FALSE;
- State->Flags.Sf = (Result & SIGN_FLAG_BYTE) ? TRUE : FALSE;
+ State->Flags.Zf = (Result == 0);
+ State->Flags.Sf = ((Result & SIGN_FLAG_BYTE) != 0);
State->Flags.Pf = Fast486CalculateParity(Result);
break;
UCHAR Result = -Value;
/* Update the flags */
- State->Flags.Cf = (Value != 0) ? TRUE : FALSE;
+ State->Flags.Cf = (Value != 0);
State->Flags.Of = (Value & SIGN_FLAG_BYTE) && (Result & SIGN_FLAG_BYTE);
- State->Flags.Af = ((Value & 0x0F) != 0) ? TRUE : FALSE;
- State->Flags.Zf = (Result == 0) ? TRUE : FALSE;
- State->Flags.Sf = (Result & SIGN_FLAG_BYTE) ? TRUE : FALSE;
+ State->Flags.Af = ((Value & 0x0F) != 0);
+ State->Flags.Zf = (Result == 0);
+ State->Flags.Sf = ((Result & SIGN_FLAG_BYTE) != 0);
State->Flags.Pf = Fast486CalculateParity(Result);
/* Write back the result */
USHORT Result = (USHORT)Value * (USHORT)State->GeneralRegs[FAST486_REG_EAX].LowByte;
/* Update the flags */
- State->Flags.Cf = State->Flags.Of = HIBYTE(Result) ? TRUE : FALSE;
+ State->Flags.Cf = State->Flags.Of = (HIBYTE(Result) != 0);
/* Write back the result */
State->GeneralRegs[FAST486_REG_EAX].LowWord = Result;
SHORT Result = (SHORT)((CHAR)Value) * (SHORT)((CHAR)State->GeneralRegs[FAST486_REG_EAX].LowByte);
/* Update the flags */
- State->Flags.Cf = State->Flags.Of =
- ((Result < -128) || (Result > 127)) ? TRUE : FALSE;
+ State->Flags.Cf = State->Flags.Of = ((Result < -128) || (Result > 127));
/* Write back the result */
State->GeneralRegs[FAST486_REG_EAX].LowWord = (USHORT)Result;
ULONG Dummy, Value = 0, SignFlag;
FAST486_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);
/* Update the flags */
State->Flags.Cf = FALSE;
State->Flags.Of = FALSE;
- State->Flags.Zf = (Result == 0) ? TRUE : FALSE;
- State->Flags.Sf = (Result & SignFlag) ? TRUE : FALSE;
+ State->Flags.Zf = (Result == 0);
+ State->Flags.Sf = ((Result & SignFlag) != 0);
State->Flags.Pf = Fast486CalculateParity(Result);
break;
if (!OperandSize) Result &= 0xFFFF;
/* Update the flags */
- State->Flags.Cf = (Value != 0) ? TRUE : FALSE;
+ State->Flags.Cf = (Value != 0);
State->Flags.Of = (Value & SignFlag) && (Result & SignFlag);
- State->Flags.Af = ((Value & 0x0F) != 0) ? TRUE : FALSE;
- State->Flags.Zf = (Result == 0) ? TRUE : FALSE;
- State->Flags.Sf = (Result & SignFlag) ? TRUE : FALSE;
+ State->Flags.Af = ((Value & 0x0F) != 0);
+ State->Flags.Zf = (Result == 0);
+ State->Flags.Sf = ((Result & SignFlag) != 0);
State->Flags.Pf = Fast486CalculateParity(Result);
/* Write back the result */
ULONGLONG Result = (ULONGLONG)Value * (ULONGLONG)State->GeneralRegs[FAST486_REG_EAX].Long;
/* Update the flags */
- State->Flags.Cf = State->Flags.Of =
- (Result & 0xFFFFFFFF00000000ULL) ? TRUE : FALSE;
+ State->Flags.Cf = State->Flags.Of = ((Result & 0xFFFFFFFF00000000ULL) != 0);
/* Write back the result */
State->GeneralRegs[FAST486_REG_EAX].Long = Result & 0xFFFFFFFFULL;
ULONG Result = (ULONG)Value * (ULONG)State->GeneralRegs[FAST486_REG_EAX].LowWord;
/* Update the flags */
- State->Flags.Cf = State->Flags.Of = HIWORD(Result) ? TRUE : FALSE;
+ State->Flags.Cf = State->Flags.Of = (HIWORD(Result) != 0);
/* Write back the result */
State->GeneralRegs[FAST486_REG_EAX].LowWord = LOWORD(Result);
LONGLONG Result = (LONGLONG)((LONG)Value) * (LONGLONG)((LONG)State->GeneralRegs[FAST486_REG_EAX].Long);
/* Update the flags */
- State->Flags.Cf = State->Flags.Of =
- ((Result < -2147483648LL) || (Result > 2147483647LL)) ? TRUE : FALSE;
+ State->Flags.Cf = State->Flags.Of = ((Result < -2147483648LL) || (Result > 2147483647LL));
/* Write back the result */
State->GeneralRegs[FAST486_REG_EAX].Long = Result & 0xFFFFFFFFULL;
LONG Result = (LONG)((SHORT)Value) * (LONG)((SHORT)State->GeneralRegs[FAST486_REG_EAX].LowWord);
/* Update the flags */
- State->Flags.Cf = State->Flags.Of =
- ((Result < -32768) || (Result > 32767)) ? TRUE : FALSE;
+ State->Flags.Cf = State->Flags.Of = ((Result < -32768) || (Result > 32767));
/* Write back the result */
State->GeneralRegs[FAST486_REG_EAX].LowWord = LOWORD(Result);
{
/* Increment and update OF and AF */
Value++;
- State->Flags.Of = (Value == SIGN_FLAG_BYTE) ? TRUE : FALSE;
+ State->Flags.Of = (Value == SIGN_FLAG_BYTE);
State->Flags.Af = ((Value & 0x0F) == 0);
}
else
{
/* Decrement and update OF and AF */
- State->Flags.Of = (Value == SIGN_FLAG_BYTE) ? TRUE : FALSE;
+ State->Flags.Of = (Value == SIGN_FLAG_BYTE);
Value--;
State->Flags.Af = ((Value & 0x0F) == 0x0F);
}
/* Update flags */
- State->Flags.Sf = (Value & SIGN_FLAG_BYTE) ? TRUE : FALSE;
- State->Flags.Zf = (Value == 0) ? TRUE : FALSE;
+ State->Flags.Zf = (Value == 0);
+ State->Flags.Sf = ((Value & SIGN_FLAG_BYTE) != 0);
State->Flags.Pf = Fast486CalculateParity(Value);
/* Write back the result */
{
FAST486_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);
{
/* Increment and update OF and AF */
Value++;
- State->Flags.Of = (Value == SIGN_FLAG_LONG) ? TRUE : FALSE;
+ State->Flags.Of = (Value == SIGN_FLAG_LONG);
State->Flags.Af = ((Value & 0x0F) == 0);
}
else if (ModRegRm.Register == 1)
{
/* Decrement and update OF and AF */
- State->Flags.Of = (Value == SIGN_FLAG_LONG) ? TRUE : FALSE;
+ State->Flags.Of = (Value == SIGN_FLAG_LONG);
Value--;
State->Flags.Af = ((Value & 0x0F) == 0x0F);
}
if (ModRegRm.Register <= 1)
{
/* Update flags */
- State->Flags.Sf = (Value & SIGN_FLAG_LONG) ? TRUE : FALSE;
- State->Flags.Zf = (Value == 0) ? TRUE : FALSE;
+ State->Flags.Sf = ((Value & SIGN_FLAG_LONG) != 0);
+ State->Flags.Zf = (Value == 0);
State->Flags.Pf = Fast486CalculateParity(Value);
/* Write back the result */
{
/* Increment and update OF */
Value++;
- State->Flags.Of = (Value == SIGN_FLAG_WORD) ? TRUE : FALSE;
+ State->Flags.Of = (Value == SIGN_FLAG_WORD);
State->Flags.Af = ((Value & 0x0F) == 0);
}
else if (ModRegRm.Register == 1)
{
/* Decrement and update OF */
- State->Flags.Of = (Value == SIGN_FLAG_WORD) ? TRUE : FALSE;
+ State->Flags.Of = (Value == SIGN_FLAG_WORD);
Value--;
State->Flags.Af = ((Value & 0x0F) == 0x0F);
}
if (ModRegRm.Register <= 1)
{
/* Update flags */
- State->Flags.Sf = (Value & SIGN_FLAG_WORD) ? TRUE : FALSE;
- State->Flags.Zf = (Value == 0) ? TRUE : FALSE;
+ State->Flags.Sf = ((Value & SIGN_FLAG_WORD) != 0);
+ State->Flags.Zf = (Value == 0);
State->Flags.Pf = Fast486CalculateParity(Value);
/* Write back the result */
BOOLEAN OperandSize, AddressSize;
UINT DataSize;
UCHAR BitNumber;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
TOGGLE_OPSIZE(OperandSize);