From: Aleksandar Andrejevic Date: Wed, 20 Nov 2013 14:21:47 +0000 (+0000) Subject: [FAST486] X-Git-Tag: backups/0.3.17@66124~1365^2~220 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=f90a1db2b70acc7d49e2eab956b90e7668b8a4fb [FAST486] The top half of EIP is cleared after a 16-bit jump. svn path=/branches/ntvdm/; revision=61058 --- diff --git a/lib/fast486/opcodes.c b/lib/fast486/opcodes.c index ac15525d8b5..b982996e967 100644 --- a/lib/fast486/opcodes.c +++ b/lib/fast486/opcodes.c @@ -606,10 +606,13 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeShortConditionalJmp) { BOOLEAN Jump = FALSE; CHAR Offset = 0; + BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF0) == 0x70); + TOGGLE_OPSIZE(Size); + /* Fetch the offset */ if (!Fast486FetchByte(State, (PUCHAR)&Offset)) { @@ -686,6 +689,12 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeShortConditionalJmp) { /* Move the instruction pointer */ State->InstPtr.Long += Offset; + + if (!Size) + { + /* Clear the top half of EIP */ + State->InstPtr.Long &= 0xFFFF; + } } /* Return success */ @@ -1058,6 +1067,9 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeOut) FAST486_OPCODE_HANDLER(Fast486OpcodeShortJump) { CHAR Offset = 0; + BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; + + TOGGLE_OPSIZE(Size); /* Make sure this is the right instruction */ ASSERT(Opcode == 0xEB); @@ -1072,6 +1084,12 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeShortJump) /* Move the instruction pointer */ State->InstPtr.Long += Offset; + if (!Size) + { + /* Clear the top half of EIP */ + State->InstPtr.Long &= 0xFFFF; + } + return TRUE; } @@ -5087,7 +5105,10 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeJmp) } /* Move the instruction pointer */ - State->InstPtr.LowWord += Offset; + State->InstPtr.Long += Offset; + + /* Clear the top half of EIP */ + State->InstPtr.Long &= 0xFFFF; } return TRUE; @@ -5137,9 +5158,8 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeJmpAbs) return FALSE; } - /* Load new (E)IP */ - if (Size) State->InstPtr.Long = Offset; - else State->InstPtr.LowWord = LOWORD(Offset); + /* Load new EIP */ + State->InstPtr.Long = Offset; return TRUE; } diff --git a/lib/fast486/opgroups.c b/lib/fast486/opgroups.c index 9519aeb0eec..1c223e0994c 100644 --- a/lib/fast486/opgroups.c +++ b/lib/fast486/opgroups.c @@ -1539,6 +1539,9 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeGroupFF) /* Set the IP to the address */ State->InstPtr.LowWord = Value; + + /* Clear the top half of EIP */ + State->InstPtr.Long &= 0xFFFF; } else if (ModRegRm.Register == 3) { @@ -1588,6 +1591,8 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeGroupFF) /* Set the IP to the address */ State->InstPtr.LowWord = Value; + /* Clear the top half of EIP */ + State->InstPtr.Long &= 0xFFFF; } else if (ModRegRm.Register == 4) { @@ -1627,6 +1632,9 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeGroupFF) /* Set the IP to the address */ State->InstPtr.LowWord = Value; + + /* Clear the top half of EIP */ + State->InstPtr.Long &= 0xFFFF; } else if (ModRegRm.Register == 6) {