{
DPRINT1("FAST486 -- Extended opcode 0x%02X is INVALID!\n", Opcode);
Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
+ return;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeUnimplemented)
{
DPRINT1("FAST486 -- Extended opcode 0x%02X is UNIMPLEMENTED\n", Opcode);
// Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcode0F0B)
{
/* Reserved opcode (UD2) */
Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeLar)
{
BOOLEAN OperandSize, AddressSize;
FAST486_MOD_REG_RM ModRegRm;
+ BOOLEAN Valid;
USHORT Selector;
FAST486_GDT_ENTRY GdtEntry;
DWORD AccessRights;
{
/* Not recognized */
Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
+ return;
}
NO_LOCK_PREFIX();
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (OperandSize)
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
Selector = LOWORD(Value);
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, NULL, &Selector))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
- if (!(Selector & SEGMENT_TABLE_INDICATOR))
+ if (!Fast486ReadDescriptorEntry(State, Selector, &Valid, &GdtEntry))
{
- /* Check if the GDT contains the entry */
- if (GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1))
- {
- State->Flags.Zf = FALSE;
- return TRUE;
- }
-
- /* Read the GDT */
- if (!Fast486ReadLinearMemory(State,
- State->Gdtr.Address
- + GET_SEGMENT_INDEX(Selector),
- &GdtEntry,
- sizeof(GdtEntry)))
- {
- /* Exception occurred */
- return FALSE;
- }
+ /* Exception occurred */
+ return;
}
- else
- {
- /* Check if the LDT contains the entry */
- if (GET_SEGMENT_INDEX(Selector) >= (State->Ldtr.Limit + 1))
- {
- State->Flags.Zf = FALSE;
- return TRUE;
- }
- /* Read the LDT */
- if (!Fast486ReadLinearMemory(State,
- State->Ldtr.Base
- + GET_SEGMENT_INDEX(Selector),
- &GdtEntry,
- sizeof(GdtEntry)))
- {
- /* Exception occurred */
- return FALSE;
- }
+ if (!Valid)
+ {
+ State->Flags.Zf = FALSE;
+ return;
}
/* Privilege check */
|| (Fast486GetCurrentPrivLevel(State) > GdtEntry.Dpl))
{
State->Flags.Zf = FALSE;
- return TRUE;
+ return;
}
/* Set ZF */
AccessRights = ((PDWORD)&GdtEntry)[1] & 0x00F0FF00;
/* Return the access rights */
- if (OperandSize)
- {
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, AccessRights))
- {
- /* Exception occurred */
- return FALSE;
- }
- }
- else
- {
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(AccessRights)))
- {
- /* Exception occurred */
- return FALSE;
- }
- }
-
- return TRUE;
+ if (OperandSize) Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, AccessRights);
+ else Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(AccessRights));
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeLsl)
{
BOOLEAN OperandSize, AddressSize;
FAST486_MOD_REG_RM ModRegRm;
+ BOOLEAN Valid;
USHORT Selector;
ULONG Limit;
FAST486_GDT_ENTRY GdtEntry;
{
/* Not recognized */
Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
+ return;
}
NO_LOCK_PREFIX();
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (OperandSize)
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
Selector = LOWORD(Value);
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, NULL, &Selector))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
- if (!(Selector & SEGMENT_TABLE_INDICATOR))
+ if (!Fast486ReadDescriptorEntry(State, Selector, &Valid, &GdtEntry))
{
- /* Check if the GDT contains the entry */
- if (GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1))
- {
- State->Flags.Zf = FALSE;
- return TRUE;
- }
-
- /* Read the GDT */
- if (!Fast486ReadLinearMemory(State,
- State->Gdtr.Address
- + GET_SEGMENT_INDEX(Selector),
- &GdtEntry,
- sizeof(GdtEntry)))
- {
- /* Exception occurred */
- return FALSE;
- }
+ /* Exception occurred */
+ return;
}
- else
- {
- /* Check if the LDT contains the entry */
- if (GET_SEGMENT_INDEX(Selector) >= (State->Ldtr.Limit + 1))
- {
- State->Flags.Zf = FALSE;
- return TRUE;
- }
- /* Read the LDT */
- if (!Fast486ReadLinearMemory(State,
- State->Ldtr.Base
- + GET_SEGMENT_INDEX(Selector),
- &GdtEntry,
- sizeof(GdtEntry)))
- {
- /* Exception occurred */
- return FALSE;
- }
+ if (!Valid)
+ {
+ State->Flags.Zf = FALSE;
+ return;
}
/* Privilege check */
|| (Fast486GetCurrentPrivLevel(State) > GdtEntry.Dpl))
{
State->Flags.Zf = FALSE;
- return TRUE;
+ return;
}
/* Calculate the limit */
Limit = GdtEntry.Limit | (GdtEntry.LimitHigh << 16);
- if (GdtEntry.Granularity) Limit <<= 12;
-
- /* Set ZF */
- State->Flags.Zf = TRUE;
- if (OperandSize)
- {
- /* Return the limit */
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Limit))
- {
- /* Exception occurred */
- return FALSE;
- }
- }
- else
+ if (GdtEntry.Granularity)
{
- /* Return the limit */
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(Limit)))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Limit <<= 12;
+ Limit |= 0x00000FFF;
}
- return TRUE;
+ /* Set ZF */
+ State->Flags.Zf = TRUE;
+
+ /* Return the limit */
+ if (OperandSize) Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Limit);
+ else Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(Limit));
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeClts)
if (Fast486GetCurrentPrivLevel(State) != 0)
{
Fast486Exception(State, FAST486_EXCEPTION_GP);
- return FALSE;
+ return;
}
/* Clear the task switch bit */
State->ControlRegisters[FAST486_REG_CR0] &= ~FAST486_CR0_TS;
-
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeStoreControlReg)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* The current privilege level must be zero */
if (Fast486GetCurrentPrivLevel(State) != 0)
{
Fast486Exception(State, FAST486_EXCEPTION_GP);
- return FALSE;
+ return;
}
if ((ModRegRm.Register == 1) || (ModRegRm.Register > 3))
{
/* CR1, CR4, CR5, CR6 and CR7 don't exist */
Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
+ return;
}
if (ModRegRm.Register != 0)
/* Store the value of the control register */
State->GeneralRegs[ModRegRm.SecondRegister].Long = State->ControlRegisters[ModRegRm.Register];
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeStoreDebugReg)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* The current privilege level must be zero */
if (Fast486GetCurrentPrivLevel(State) != 0)
{
Fast486Exception(State, FAST486_EXCEPTION_GP);
- return FALSE;
+ return;
}
if ((ModRegRm.Register == 6) || (ModRegRm.Register == 7))
{
/* Disallow access to debug registers */
Fast486Exception(State, FAST486_EXCEPTION_GP);
- return FALSE;
+ return;
}
/* Store the value of the debug register */
State->GeneralRegs[ModRegRm.SecondRegister].Long = State->DebugRegisters[ModRegRm.Register];
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeLoadControlReg)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* The current privilege level must be zero */
if (Fast486GetCurrentPrivLevel(State) != 0)
{
Fast486Exception(State, FAST486_EXCEPTION_GP);
- return FALSE;
+ return;
}
if ((ModRegRm.Register == 1) || (ModRegRm.Register > 3))
{
/* CR1, CR4, CR5, CR6 and CR7 don't exist */
Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
+ return;
}
if (ModRegRm.Register != 0)
{
/* Invalid value */
Fast486Exception(State, FAST486_EXCEPTION_GP);
- return FALSE;
+ return;
}
}
+#ifndef FAST486_NO_PREFETCH
+ /* Changing CR0 or CR3 can interfere with prefetching (because of paging) */
+ State->PrefetchValid = FALSE;
+#endif
+
+ if (State->Tlb && (ModRegRm.Register == (INT)FAST486_REG_CR3))
+ {
+ /* Flush the TLB */
+ RtlZeroMemory(State->Tlb, NUM_TLB_ENTRIES * sizeof(ULONG));
+ }
+
/* Load a value to the control register */
State->ControlRegisters[ModRegRm.Register] = Value;
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeLoadDebugReg)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* The current privilege level must be zero */
if (Fast486GetCurrentPrivLevel(State) != 0)
{
Fast486Exception(State, FAST486_EXCEPTION_GP);
- return FALSE;
+ return;
}
if ((ModRegRm.Register == 6) || (ModRegRm.Register == 7))
{
/* Disallow access to debug registers */
Fast486Exception(State, FAST486_EXCEPTION_GP);
- return FALSE;
+ return;
}
/* Load a value to the debug register */
/* The reserved bits are 0 */
State->DebugRegisters[ModRegRm.Register] &= ~FAST486_DR5_RESERVED;
}
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodePushFs)
{
/* Call the internal API */
- return Fast486StackPush(State, State->SegmentRegs[FAST486_REG_FS].Selector);
+ Fast486StackPush(State, State->SegmentRegs[FAST486_REG_FS].Selector);
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodePopFs)
if (!Fast486StackPop(State, &NewSelector))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Call the internal API */
- return Fast486LoadSegment(State, FAST486_REG_FS, LOWORD(NewSelector));
+ Fast486LoadSegment(State, FAST486_REG_FS, LOWORD(NewSelector));
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBitTest)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Get the bit number */
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Set CF to the bit value */
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Set CF to the bit value */
State->Flags.Cf = (Value >> BitNumber) & 1;
}
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeShld)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (Opcode == 0xA4)
if (!Fast486FetchByte(State, &Count))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
else
Count &= 0x1F;
/* Do nothing if the count is zero */
- if (Count == 0) return TRUE;
+ if (Count == 0) return;
if (OperandSize)
{
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, &Source, &Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Calculate the result */
State->Flags.Pf = Fast486CalculateParity(Result);
/* Write back the result */
- return Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result);
+ Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result);
}
else
{
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Source, &Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
DoubleSource = Source | (Source << 16);
State->Flags.Pf = Fast486CalculateParity(Result);
/* Write back the result */
- return Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result);
+ Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result);
}
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodePushGs)
{
/* Call the internal API */
- return Fast486StackPush(State, State->SegmentRegs[FAST486_REG_GS].Selector);
+ Fast486StackPush(State, State->SegmentRegs[FAST486_REG_GS].Selector);
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodePopGs)
if (!Fast486StackPop(State, &NewSelector))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Call the internal API */
- return Fast486LoadSegment(State, FAST486_REG_GS, LOWORD(NewSelector));
+ Fast486LoadSegment(State, FAST486_REG_GS, LOWORD(NewSelector));
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBts)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Get the bit number */
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Set CF to the bit value */
Value |= 1 << BitNumber;
/* Write back the result */
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value);
}
else
{
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Set CF to the bit value */
Value |= 1 << BitNumber;
/* Write back the result */
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value);
}
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeShrd)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (Opcode == 0xAC)
if (!Fast486FetchByte(State, &Count))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
else
Count &= 0x1F;
/* Do nothing if the count is zero */
- if (Count == 0) return TRUE;
+ if (Count == 0) return;
if (OperandSize)
{
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, &Source, &Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Calculate the result */
State->Flags.Pf = Fast486CalculateParity(Result);
/* Write back the result */
- return Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result);
+ Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result);
}
else
{
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Source, &Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Calculate the result */
State->Flags.Pf = Fast486CalculateParity(Result);
/* Write back the result */
- return Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result);
+ Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result);
}
}
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (OperandSize)
(PULONG)&Source))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Calculate the result */
State->Flags.Cf = State->Flags.Of = ((Result < -2147483648LL) || (Result > 2147483647LL));
/* Write back the result */
- return Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, (ULONG)((LONG)Result));
+ Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, (ULONG)((LONG)Result));
}
else
{
(PUSHORT)&Source))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Calculate the result */
State->Flags.Cf = State->Flags.Of = ((Result < -32768) || (Result > 32767));
/* Write back the result */
- return Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, (USHORT)((SHORT)Result));
+ Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, (USHORT)((SHORT)Result));
}
}
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Read the operands */
if (!Fast486ReadModrmByteOperands(State, &ModRegRm, &Source, &Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Compare AL with the destination */
if (State->Flags.Zf)
{
/* Load the source operand into the destination */
- return Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Source);
+ Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Source);
}
else
{
/* Load the destination into AL */
State->GeneralRegs[FAST486_REG_EAX].LowByte = Destination;
}
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchg)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (OperandSize)
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, &Source, &Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Compare EAX with the destination */
if (State->Flags.Zf)
{
/* Load the source operand into the destination */
- return Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Source);
+ Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Source);
}
else
{
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Source, &Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Compare AX with the destination */
if (State->Flags.Zf)
{
/* Load the source operand into the destination */
- return Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Source);
+ Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Source);
}
else
{
State->GeneralRegs[FAST486_REG_EAX].LowWord = Destination;
}
}
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeLss)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (!ModRegRm.Memory)
{
/* Invalid */
Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
+ return;
}
if (!Fast486ReadMemory(State,
OperandSize ? 6 : 4))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (OperandSize)
State->GeneralRegs[ModRegRm.Register].Long = Offset;
/* Load the segment */
- return Fast486LoadSegment(State,
- FAST486_REG_SS,
- Segment);
+ Fast486LoadSegment(State, FAST486_REG_SS, Segment);
}
else
{
State->GeneralRegs[ModRegRm.Register].LowWord = Offset;
/* Load the segment */
- return Fast486LoadSegment(State,
- FAST486_REG_SS,
- Segment);
+ Fast486LoadSegment(State, FAST486_REG_SS, Segment);
}
}
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Get the bit number */
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Set CF to the bit value */
Value &= ~(1 << BitNumber);
/* Write back the result */
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value);
}
else
{
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Set CF to the bit value */
Value &= ~(1 << BitNumber);
/* Write back the result */
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value);
}
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeLfsLgs)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (!ModRegRm.Memory)
{
/* Invalid */
Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
+ return;
}
if (!Fast486ReadMemory(State,
OperandSize ? 6 : 4))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (OperandSize)
State->GeneralRegs[ModRegRm.Register].Long = Offset;
/* Load the segment */
- return Fast486LoadSegment(State,
- (Opcode == 0xB4)
- ? FAST486_REG_FS : FAST486_REG_GS,
- Segment);
+ Fast486LoadSegment(State,
+ (Opcode == 0xB4)
+ ? FAST486_REG_FS : FAST486_REG_GS,
+ Segment);
}
else
{
State->GeneralRegs[ModRegRm.Register].LowWord = Offset;
/* Load the segment */
- return Fast486LoadSegment(State,
- (Opcode == 0xB4)
- ? FAST486_REG_FS : FAST486_REG_GS,
- Segment);
+ Fast486LoadSegment(State,
+ (Opcode == 0xB4)
+ ? FAST486_REG_FS : FAST486_REG_GS,
+ Segment);
}
}
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Read the operands */
if (!Fast486ReadModrmByteOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Write back the zero-extended value */
- return Fast486WriteModrmDwordOperands(State,
- &ModRegRm,
- TRUE,
- (ULONG)Value);
+ Fast486WriteModrmDwordOperands(State,
+ &ModRegRm,
+ TRUE,
+ (ULONG)Value);
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeMovzxWord)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Read the operands */
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Write back the zero-extended value */
- return Fast486WriteModrmDwordOperands(State,
- &ModRegRm,
- TRUE,
- (ULONG)Value);
+ Fast486WriteModrmDwordOperands(State,
+ &ModRegRm,
+ TRUE,
+ (ULONG)Value);
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBtc)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Get the bit number */
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Set CF to the bit value */
Value ^= 1 << BitNumber;
/* Write back the result */
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value);
}
else
{
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Set CF to the bit value */
Value ^= 1 << BitNumber;
/* Write back the result */
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value);
}
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsf)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Read the value */
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
else
(PUSHORT)&Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
/* Set ZF */
State->Flags.Zf = (Value == 0);
- if (State->Flags.Zf) return TRUE;
+ if (State->Flags.Zf) return;
for (i = 0; i < DataSize; i++)
{
- if(Value & (1 << i))
+ if (Value & (1 << i))
{
/* Save the bit number */
BitNumber = i;
}
/* Write back the result */
- if (OperandSize)
- {
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber))
- {
- /* Exception occurred */
- return FALSE;
- }
- }
- else
- {
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber)))
- {
- /* Exception occurred */
- return FALSE;
- }
- }
-
- return TRUE;
+ if (OperandSize) Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber);
+ else Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber));
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBsr)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Read the value */
if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, NULL, &Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
else
(PUSHORT)&Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
/* Set ZF according to the value */
State->Flags.Zf = (Value == 0);
- if (State->Flags.Zf) return TRUE;
+ if (State->Flags.Zf) return;
for (i = DataSize - 1; i >= 0; i--)
{
- if(Value & (1 << i))
+ if (Value & (1 << i))
{
/* Save the bit number */
BitNumber = i;
}
/* Write back the result */
- if (OperandSize)
- {
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber))
- {
- /* Exception occurred */
- return FALSE;
- }
- }
- else
- {
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber)))
- {
- /* Exception occurred */
- return FALSE;
- }
- }
-
- return TRUE;
+ if (OperandSize) Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber);
+ else Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber));
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeMovsxByte)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Read the operands */
if (!Fast486ReadModrmByteOperands(State, &ModRegRm, NULL, (PUCHAR)&Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Write back the sign-extended value */
- return Fast486WriteModrmDwordOperands(State,
- &ModRegRm,
- TRUE,
- (ULONG)((LONG)Value));
+ Fast486WriteModrmDwordOperands(State,
+ &ModRegRm,
+ TRUE,
+ (ULONG)((LONG)Value));
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeMovsxWord)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Read the operands */
if (!Fast486ReadModrmWordOperands(State, &ModRegRm, NULL, (PUSHORT)&Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Write back the sign-extended value */
- return Fast486WriteModrmDwordOperands(State,
- &ModRegRm,
- TRUE,
- (ULONG)((LONG)Value));
+ Fast486WriteModrmDwordOperands(State,
+ &ModRegRm,
+ TRUE,
+ (ULONG)((LONG)Value));
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalJmp)
if (!Fast486FetchDword(State, (PULONG)&Offset))
{
/* Exception occurred */
- return FALSE;
+ return;
}
}
else
if (!Fast486FetchWord(State, (PUSHORT)&Value))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Sign-extend */
/* Move the instruction pointer */
State->InstPtr.Long += Offset;
}
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalSet)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Make sure this is the right instruction */
}
/* Write back the result */
- return Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Value);
+ Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Value);
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeXaddByte)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
if (!Fast486ReadModrmByteOperands(State,
&Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Calculate the result */
if (!Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Result))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Write the old value of the destination to the source */
- if (!Fast486WriteModrmByteOperands(State, &ModRegRm, TRUE, Destination))
- {
- /* Exception occurred */
- return FALSE;
- }
-
- return TRUE;
+ Fast486WriteModrmByteOperands(State, &ModRegRm, TRUE, Destination);
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeXadd)
if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Check the operand size */
&Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Calculate the result */
if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Write the sum to the destination */
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result);
}
else
{
&Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Calculate the result */
if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, Destination))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Write the sum to the destination */
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result))
- {
- /* Exception occurred */
- return FALSE;
- }
+ Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result);
}
-
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBswap)
/* Swap the byte order */
SWAP(Pointer[0], Pointer[3]);
SWAP(Pointer[1], Pointer[2]);
-
- /* Return success */
- return TRUE;
}
FAST486_OPCODE_HANDLER(Fast486OpcodeExtended)
if (!Fast486FetchByte(State, &SecondOpcode))
{
/* Exception occurred */
- return FALSE;
+ return;
}
/* Call the extended opcode handler */
- return Fast486ExtendedHandlers[SecondOpcode](State, SecondOpcode);
+ Fast486ExtendedHandlers[SecondOpcode](State, SecondOpcode);
}
/* EOF */