/* Task call */
return Fast486TaskSwitch(State, FAST486_TASK_CALL, IdtEntry->Selector);
}
-
+
if (GateSize != (State->SegmentRegs[FAST486_REG_CS].Size))
{
/* The gate size doesn't match the current operand size, so set the OPSIZE flag. */
/* Make sure the entry exists in the GDT (not LDT!) */
if ((GET_SEGMENT_INDEX(Selector) == 0)
|| (Selector & SEGMENT_TABLE_INDICATOR)
- || GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1))
+ || GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1u))
{
Fast486ExceptionWithErrorCode(State, FAST486_EXCEPTION_TS, Selector);
return FALSE;
&& ((NewTssDescriptor.Signature != FAST486_BUSY_TSS_SIGNATURE)
|| (Type != FAST486_TASK_RETURN)))
{
- Fast486ExceptionWithErrorCode(State, FAST486_EXCEPTION_GP, Selector);
+ Fast486ExceptionWithErrorCode(State, FAST486_EXCEPTION_GP, Selector);
return FALSE;
}
/* Block size for string operations */
#define STRING_BLOCK_SIZE 4096
-#define GET_SEGMENT_RPL(s) ((s) & 3)
-#define GET_SEGMENT_INDEX(s) ((s) & 0xFFF8)
+#define GET_SEGMENT_RPL(s) ((s) & 3u)
+#define GET_SEGMENT_INDEX(s) ((s) & 0xFFF8u)
#define SEGMENT_TABLE_INDICATOR (1 << 2)
#define EXCEPTION_HAS_ERROR_CODE(x) (((x) == 8) || ((x) >= 10 && (x) <= 14))
#endif
FORCEINLINE
-INT
+UINT
FASTCALL
Fast486GetCurrentPrivLevel(PFAST486_STATE State)
{
if (!(Selector & SEGMENT_TABLE_INDICATOR))
{
/* Make sure the GDT contains the entry */
- if (GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1))
+ if (GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1u))
{
*EntryValid = FALSE;
return TRUE;
else
{
/* Make sure the LDT contains the entry */
- if (GET_SEGMENT_INDEX(Selector) >= (State->Ldtr.Limit + 1))
+ if (GET_SEGMENT_INDEX(Selector) >= (State->Ldtr.Limit + 1u))
{
*EntryValid = FALSE;
return TRUE;
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_NE)
{
/* Call the #MF handler */
- Fast486Exception(State, FAST486_EXCEPTION_MF);
+ Fast486Exception(State, FAST486_EXCEPTION_MF);
}
else
{
{
/* Raise the stack fault and invalid operation exception */
State->FpuStatus.Sf = State->FpuStatus.Ie = TRUE;
-
+
/* Set the C1 condition code bit (stack overflow) */
State->FpuStatus.Code1 = TRUE;
/* Exception occurred */
return;
}
-
+
Selector = LOWORD(Value);
}
else
/* Exception occurred */
return;
}
-
+
Selector = LOWORD(Value);
}
else
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsf)
{
- INT i;
+ UINT i;
ULONG Value = 0;
BOOLEAN OperandSize, AddressSize;
FAST486_MOD_REG_RM ModRegRm;
ULONG MultiplicandLow, MultiplicandHigh, MultiplierLow, MultiplierHigh;
ULONG IntermediateLow, IntermediateHigh;
ULONGLONG LowProduct, Intermediate, Intermediate1, Intermediate2;
-
+
MultiplicandLow = (ULONG)(Multiplicand & 0xFFFFFFFFULL);
MultiplicandHigh = (ULONG)(Multiplicand >> 32);
MultiplierLow = (ULONG)(Multiplier & 0xFFFFFFFFULL);
Result->Mantissa = (ULONGLONG)Value;
ZeroCount = CountLeadingZeros64(Result->Mantissa);
-
+
Result->Mantissa <<= ZeroCount;
Result->Exponent = FPU_REAL10_BIAS + 63 - ZeroCount;
}
*Result = 0LL;
return TRUE;
}
-
+
if (FPU_IS_NAN(Value) || !FPU_IS_NORMALIZED(Value)
|| (UnbiasedExp < 0) || (UnbiasedExp > 63))
{
else TempResult.Sign = FALSE;
/* Invert the negative mantissa */
- if (FirstAdjusted.Sign) FirstAdjusted.Mantissa = -FirstAdjusted.Mantissa;
- if (SecondAdjusted.Sign) SecondAdjusted.Mantissa = -SecondAdjusted.Mantissa;
+ if (FirstAdjusted.Sign) FirstAdjusted.Mantissa = -(LONGLONG)FirstAdjusted.Mantissa;
+ if (SecondAdjusted.Sign) SecondAdjusted.Mantissa = -(LONGLONG)SecondAdjusted.Mantissa;
/* Calculate the mantissa of the result */
TempResult.Mantissa = FirstAdjusted.Mantissa + SecondAdjusted.Mantissa;
TempResult.Exponent++;
}
}
-
+
/* Normalize the result and return it */
Fast486FpuNormalize(State, &TempResult);
*Result = TempResult;
}
if (FPU_IS_INFINITY(FirstOperand) || FPU_IS_INFINITY(SecondOperand))
- {
+ {
/* The result will be infinity */
Result->Sign = FirstOperand->Sign ^ SecondOperand->Sign;
Result->Exponent = FPU_MAX_EXPONENT + 1;
{
/* Raise the underflow exception */
State->FpuStatus.Ue = TRUE;
-
+
if (!State->FpuControl.Um)
{
Fast486FpuException(State);
if (State->FpuControl.Im)
{
- /* Return the indefinite NaN */
+ /* Return the indefinite NaN */
Result->Sign = TRUE;
Result->Exponent = FPU_MAX_EXPONENT + 1;
Result->Mantissa = FPU_INDEFINITE_MANTISSA;
/* Divide the two mantissas */
Remainder = UnsignedDivMod128(0ULL,
/* Notice the 64 above - this is the high part */
- FirstOperand->Mantissa,
+ FirstOperand->Mantissa,
SecondOperand->Mantissa,
&QuotientLow,
&QuotientHigh);
SourceOperand = &MemoryData;
/* Perform the requested operation */
- Fast486FpuArithmeticOperation(State, ModRegRm.Register, SourceOperand, DestOperand);
+ Fast486FpuArithmeticOperation(State, ModRegRm.Register, SourceOperand, DestOperand);
#endif
}
Value.Exponent = *((PUSHORT)&Buffer[8]) & (FPU_MAX_EXPONENT + 1);
Value.Sign = *((PUCHAR)&Buffer[9]) >> 7;
- Fast486FpuPush(State, &Value);
+ Fast486FpuPush(State, &Value);
break;
}
return;
}
- Fast486FpuPop(State);
+ Fast486FpuPop(State);
break;
}
}
/* Perform the requested operation */
- Fast486FpuArithmeticOperation(State, ModRegRm.Register, SourceOperand, DestOperand);
+ Fast486FpuArithmeticOperation(State, ModRegRm.Register, SourceOperand, DestOperand);
if (!ModRegRm.Memory) Fast486FpuPop(State);
#endif
return;
}
- Fast486FpuPop(State);
+ Fast486FpuPop(State);
break;
}
FAST486_OPCODE_HANDLER(Fast486OpcodePopFlags)
{
BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size;
- INT Cpl = Fast486GetCurrentPrivLevel(State);
+ UINT Cpl = Fast486GetCurrentPrivLevel(State);
FAST486_FLAGS_REG NewFlags;
NO_LOCK_PREFIX();
if ((State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE) && !State->Flags.Vm)
{
- INT i;
- INT OldCpl = Fast486GetCurrentPrivLevel(State);
+ UINT i;
+ UINT OldCpl = Fast486GetCurrentPrivLevel(State);
ULONG StackPtr;
ULONG StackSel;
-
+
if (GET_SEGMENT_RPL(Segment) > OldCpl)
{
/* Pop ESP */
/* Check for protected mode */
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE)
{
- INT OldCpl = Fast486GetCurrentPrivLevel(State);
+ UINT OldCpl = Fast486GetCurrentPrivLevel(State);
if (State->Flags.Vm)
{
FAST486_OPCODE_HANDLER(Fast486OpcodeMovOffsetEax)
{
BOOLEAN OperandSize, AddressSize;
-
+
OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
/* Make sure this is the right instruction */
|| (!AddressSize && (State->GeneralRegs[FAST486_REG_ECX].LowWord == 0)))
{
/* Do nothing */
- return;
+ return;
}
}
case 2:
{
Result = (Value << Count) | (State->Flags.Cf << (Count - 1));
-
+
/* Complete the calculation, but make sure we don't shift by too much */
if ((Bits - Count) < 31) Result |= Value >> (Bits - Count + 1);
Quotient = State->GeneralRegs[FAST486_REG_EAX].LowWord / Value;
Remainder = State->GeneralRegs[FAST486_REG_EAX].LowWord % Value;
- if (Quotient > 0xFF)
+ if (Quotient > 0xFF)
{
/* Divide error */
Fast486Exception(State, FAST486_EXCEPTION_DE);
Quotient = (SHORT)State->GeneralRegs[FAST486_REG_EAX].LowWord / (CHAR)Value;
Remainder = (SHORT)State->GeneralRegs[FAST486_REG_EAX].LowWord % (CHAR)Value;
- if (Quotient > 127 || Quotient < -128)
+ if (Quotient > 127 || Quotient < -128)
{
/* Divide error */
Fast486Exception(State, FAST486_EXCEPTION_DE);
case 3:
{
/* Calculate the result */
- ULONG Result = -Value;
+ ULONG Result = -(LONG)Value;
if (!OperandSize) Result &= 0xFFFF;
/* Update the flags */