From 6a2d76ab68e9af6ebb2d88c7077189798ad25bac Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sat, 21 Sep 2013 02:18:41 +0000 Subject: [PATCH] [SOFT386] Fix prefix handling. svn path=/branches/ntvdm/; revision=60260 --- lib/soft386/opcodes.c | 95 +++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/lib/soft386/opcodes.c b/lib/soft386/opcodes.c index 88dcdfa361a..3632f4024e5 100644 --- a/lib/soft386/opcodes.c +++ b/lib/soft386/opcodes.c @@ -1425,18 +1425,19 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeAddEax) /* Make sure this is the right instruction */ ASSERT(Opcode == 0x05); - if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - else + if (State->PrefixFlags & SOFT386_PREFIX_LOCK) { /* Invalid prefix */ Soft386Exception(State, SOFT386_EXCEPTION_UD); return FALSE; } + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + if (Size) { ULONG FirstValue = State->GeneralRegs[SOFT386_REG_EAX].Long; @@ -1695,18 +1696,19 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeOrEax) /* Make sure this is the right instruction */ ASSERT(Opcode == 0x0D); - if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - else + if (State->PrefixFlags & SOFT386_PREFIX_LOCK) { /* Invalid prefix */ Soft386Exception(State, SOFT386_EXCEPTION_UD); return FALSE; } + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + if (Size) { ULONG FirstValue = State->GeneralRegs[SOFT386_REG_EAX].Long; @@ -1925,9 +1927,9 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeAndAl) /* Make sure this is the right instruction */ ASSERT(Opcode == 0x24); - if (State->PrefixFlags) + if (State->PrefixFlags & SOFT386_PREFIX_LOCK) { - /* This opcode doesn't take any prefixes */ + /* Invalid prefix */ Soft386Exception(State, SOFT386_EXCEPTION_UD); return FALSE; } @@ -1961,18 +1963,19 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeAndEax) /* Make sure this is the right instruction */ ASSERT(Opcode == 0x25); - if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - else + if (State->PrefixFlags & SOFT386_PREFIX_LOCK) { /* Invalid prefix */ Soft386Exception(State, SOFT386_EXCEPTION_UD); return FALSE; } + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + if (Size) { ULONG FirstValue = State->GeneralRegs[SOFT386_REG_EAX].Long; @@ -2227,18 +2230,19 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeXorEax) /* Make sure this is the right instruction */ ASSERT(Opcode == 0x35); - if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - else + if (State->PrefixFlags & SOFT386_PREFIX_LOCK) { /* Invalid prefix */ Soft386Exception(State, SOFT386_EXCEPTION_UD); return FALSE; } + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + if (Size) { ULONG FirstValue = State->GeneralRegs[SOFT386_REG_EAX].Long; @@ -2478,18 +2482,19 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeTestEax) /* Make sure this is the right instruction */ ASSERT(Opcode == 0xA9); - if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - else + if (State->PrefixFlags & SOFT386_PREFIX_LOCK) { /* Invalid prefix */ Soft386Exception(State, SOFT386_EXCEPTION_UD); return FALSE; } + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + if (Size) { ULONG FirstValue = State->GeneralRegs[SOFT386_REG_EAX].Long; @@ -2965,18 +2970,19 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeAdcEax) /* Make sure this is the right instruction */ ASSERT(Opcode == 0x15); - if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - else + if (State->PrefixFlags & SOFT386_PREFIX_LOCK) { /* Invalid prefix */ Soft386Exception(State, SOFT386_EXCEPTION_UD); return FALSE; } + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + if (Size) { ULONG FirstValue = State->GeneralRegs[SOFT386_REG_EAX].Long; @@ -3418,18 +3424,19 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeCmpSubEax) /* Make sure this is the right instruction */ ASSERT((Opcode & 0xEF) == 0x2D); - if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - else + if (State->PrefixFlags & SOFT386_PREFIX_LOCK) { /* Invalid prefix */ Soft386Exception(State, SOFT386_EXCEPTION_UD); return FALSE; } + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + if (Size) { ULONG FirstValue = State->GeneralRegs[SOFT386_REG_EAX].Long;