* Fast486 386/486 CPU Emulation Library
* extraops.c
*
- * Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
FAST486_OPCODE_HANDLER_PROC
Fast486ExtendedHandlers[FAST486_NUM_OPCODE_HANDLERS] =
{
- Fast486OpcodeGroup0F00,
- Fast486OpcodeGroup0F01,
- Fast486ExtOpcodeLar,
- Fast486ExtOpcodeLsl,
- NULL, // Invalid
- NULL, // Invalid
- Fast486ExtOpcodeClts,
- NULL, // Invalid
- NULL, // TODO: OPCODE 0x08 NOT IMPLEMENTED
- NULL, // TODO: OPCODE 0x09 NOT IMPLEMENTED
- NULL, // Invalid
- NULL, // Reserved (UD1)
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- Fast486ExtOpcodeStoreControlReg,
- Fast486ExtOpcodeStoreDebugReg,
- Fast486ExtOpcodeLoadControlReg,
- Fast486ExtOpcodeLoadDebugReg,
- NULL, // TODO: OPCODE 0x24 NOT IMPLEMENTED
- NULL, // Invalid
- NULL, // TODO: OPCODE 0x26 NOT IMPLEMENTED
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
+ Fast486ExtOpcodeGroup0F00, /* 0x00 - 0x01 */
+ Fast486ExtOpcodeGroup0F01,
+ Fast486ExtOpcodeLar, /* 0x02 */
+ Fast486ExtOpcodeLsl, /* 0x03 */
+ Fast486ExtOpcodeInvalid, /* 0x04 - 0x05 */ // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeClts, /* 0x06 */
+ Fast486ExtOpcodeInvalid, /* 0x07 */ // Invalid
+ Fast486ExtOpcodeUnimplemented, // TODO: OPCODE 0x08 NOT IMPLEMENTED
+ Fast486ExtOpcodeUnimplemented, // TODO: OPCODE 0x09 NOT IMPLEMENTED
+ Fast486ExtOpcodeInvalid, /* 0x0A */ // Invalid
+ Fast486ExtOpcode0F0B, /* 0x0B */ // Reserved (UD2)
+ Fast486ExtOpcodeInvalid, /* 0x0C - 0x1F */ // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeStoreControlReg, /* 0x20 */
+ Fast486ExtOpcodeStoreDebugReg, /* 0x21 */
+ Fast486ExtOpcodeLoadControlReg, /* 0x22 */
+ Fast486ExtOpcodeLoadDebugReg, /* 0x23 */
+ Fast486ExtOpcodeUnimplemented, // TODO: OPCODE 0x24 NOT IMPLEMENTED
+ Fast486ExtOpcodeInvalid, /* 0x25 */ // Invalid
+ Fast486ExtOpcodeUnimplemented, // TODO: OPCODE 0x26 NOT IMPLEMENTED
+ Fast486ExtOpcodeInvalid, /* 0x27 - 0x7F */ // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeConditionalJmp, /* 0x80 - 0x8F */
Fast486ExtOpcodeConditionalJmp,
Fast486ExtOpcodeConditionalJmp,
Fast486ExtOpcodeConditionalJmp,
Fast486ExtOpcodeConditionalJmp,
Fast486ExtOpcodeConditionalJmp,
Fast486ExtOpcodeConditionalJmp,
- Fast486ExtOpcodeConditionalJmp,
- Fast486ExtOpcodeConditionalSet,
+ Fast486ExtOpcodeConditionalSet, /* 0x90 - 0x9F */
Fast486ExtOpcodeConditionalSet,
Fast486ExtOpcodeConditionalSet,
Fast486ExtOpcodeConditionalSet,
Fast486ExtOpcodeConditionalSet,
Fast486ExtOpcodeConditionalSet,
Fast486ExtOpcodeConditionalSet,
- Fast486ExtOpcodePushFs,
- Fast486ExtOpcodePopFs,
- NULL, // Invalid
- Fast486ExtOpcodeBitTest,
- Fast486ExtOpcodeShld,
+ Fast486ExtOpcodePushFs, /* 0xA0 */
+ Fast486ExtOpcodePopFs, /* 0xA1 */
+ Fast486ExtOpcodeInvalid, /* 0xA2 */ // Invalid
+ Fast486ExtOpcodeBitTest, /* 0xA3 */
+ Fast486ExtOpcodeShld, /* 0xA4 - 0xA5 */
Fast486ExtOpcodeShld,
- NULL, // Invalid
- NULL, // Invalid
- Fast486ExtOpcodePushGs,
+ Fast486ExtOpcodeInvalid, /* 0xA6 - 0xA7 */ // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodePushGs, /* 0xA8 - 0xA9 */
Fast486ExtOpcodePopGs,
- NULL, // Invalid
- Fast486ExtOpcodeBts,
+ Fast486ExtOpcodeInvalid, /* 0xAA */ // Invalid
+ Fast486ExtOpcodeBts, /* 0xAB */
+ Fast486ExtOpcodeShrd, /* 0xAC - 0xAD */
Fast486ExtOpcodeShrd,
- Fast486ExtOpcodeShrd,
- NULL, // Invalid
- Fast486ExtOpcodeImul,
- Fast486ExtOpcodeCmpXchgByte,
- Fast486ExtOpcodeCmpXchg,
- Fast486ExtOpcodeLss,
- Fast486ExtOpcodeBtr,
- Fast486ExtOpcodeLfsLgs,
+ Fast486ExtOpcodeInvalid, /* 0xAE */ // Invalid
+ Fast486ExtOpcodeImul, /* 0xAF */
+ Fast486ExtOpcodeCmpXchgByte, /* 0xB0 */
+ Fast486ExtOpcodeCmpXchg, /* 0xB1 */
+ Fast486ExtOpcodeLss, /* 0xB2 */
+ Fast486ExtOpcodeBtr, /* 0xB3 */
+ Fast486ExtOpcodeLfsLgs, /* 0xB4 - 0xB5 */
Fast486ExtOpcodeLfsLgs,
- Fast486ExtOpcodeMovzxByte,
+ Fast486ExtOpcodeMovzxByte, /* 0xB6 - 0xB7 */
Fast486ExtOpcodeMovzxWord,
- NULL, // Invalid
- Fast486OpcodeGroup0FB9,
- Fast486OpcodeGroup0FBA,
- Fast486ExtOpcodeBtc,
- Fast486ExtOpcodeBsf,
- Fast486ExtOpcodeBsr,
- Fast486ExtOpcodeMovsxByte,
+ Fast486ExtOpcodeInvalid, /* 0xB8 */ // Invalid
+ Fast486ExtOpcodeGroup0FB9, /* 0xB9 */
+ Fast486ExtOpcodeGroup0FBA, /* 0xBA */
+ Fast486ExtOpcodeBtc, /* 0xBB */
+ Fast486ExtOpcodeBsf, /* 0xBC */
+ Fast486ExtOpcodeBsr, /* 0xBD */
+ Fast486ExtOpcodeMovsxByte, /* 0xBE - 0xBF */
Fast486ExtOpcodeMovsxWord,
- Fast486ExtOpcodeXaddByte,
+ Fast486ExtOpcodeXaddByte, /* 0xC0 - 0xC1 */
Fast486ExtOpcodeXadd,
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- Fast486ExtOpcodeBswap,
+ Fast486ExtOpcodeInvalid, /* 0xC2 - 0xC7 */ // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeBswap, /* 0xC8 - 0xCF */
Fast486ExtOpcodeBswap,
Fast486ExtOpcodeBswap,
Fast486ExtOpcodeBswap,
Fast486ExtOpcodeBswap,
Fast486ExtOpcodeBswap,
Fast486ExtOpcodeBswap,
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
- NULL, // Invalid
+ Fast486ExtOpcodeInvalid, /* 0xD0 - 0xFF */ // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
+ Fast486ExtOpcodeInvalid, // Invalid
};
/* PUBLIC FUNCTIONS ***********************************************************/
+FAST486_OPCODE_HANDLER(Fast486ExtOpcodeInvalid)
+{
+ DPRINT1("FAST486 -- Extended opcode 0x%02X is INVALID!\n", Opcode);
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return;
+}
+
+FAST486_OPCODE_HANDLER(Fast486ExtOpcodeUnimplemented)
+{
+ DPRINT1("FAST486 -- Extended opcode 0x%02X is UNIMPLEMENTED\n", Opcode);
+ // Fast486Exception(State, FAST486_EXCEPTION_UD);
+}
+
+FAST486_OPCODE_HANDLER(Fast486ExtOpcode0F0B)
+{
+ /* Reserved opcode (UD2) */
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+}
+
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 */
ULONG Source, Destination, Result;
if (!Fast486ReadModrmDwordOperands(State,
- &ModRegRm,
- &Source,
- &Destination))
+ &ModRegRm,
+ &Source,
+ &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;
}
- if (Fast486ExtendedHandlers[SecondOpcode] != NULL)
- {
- /* Call the extended opcode handler */
- return Fast486ExtendedHandlers[SecondOpcode](State, SecondOpcode);
- }
- else
- {
- /* This is not a valid opcode */
- Fast486Exception(State, FAST486_EXCEPTION_UD);
- return FALSE;
- }
+ /* Call the extended opcode handler */
+ Fast486ExtendedHandlers[SecondOpcode](State, SecondOpcode);
}
+/* EOF */