From 429d182d646bfd3a236a1e1ede3311c51190cefa Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sun, 15 Sep 2013 18:18:58 +0000 Subject: [PATCH] [SOFT386] Implement JMP rel16/32 svn path=/branches/ntvdm/; revision=60146 --- lib/soft386/opcodes.c | 49 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/soft386/opcodes.c b/lib/soft386/opcodes.c index 9d3b9bb3592..c9fcd5f94aa 100644 --- a/lib/soft386/opcodes.c +++ b/lib/soft386/opcodes.c @@ -4212,10 +4212,53 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeCall) SOFT386_OPCODE_HANDLER(Soft386OpcodeJmp) { - // TODO: NOT IMPLEMENTED - UNIMPLEMENTED; + BOOLEAN Size = State->SegmentRegs[SOFT386_REG_CS].Size; - return FALSE; + /* Make sure this is the right instruction */ + ASSERT(Opcode == 0xE9); + + if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + else if (State->PrefixFlags != 0) + { + /* Invalid prefix */ + Soft386Exception(State, SOFT386_EXCEPTION_UD); + return FALSE; + } + + if (Size) + { + LONG Offset = 0; + + /* Fetch the offset */ + if (!Soft386FetchDword(State, (PULONG)&Offset)) + { + /* An exception occurred */ + return FALSE; + } + + /* Move the instruction pointer */ + State->InstPtr.Long += Offset; + } + else + { + SHORT Offset = 0; + + /* Fetch the offset */ + if (!Soft386FetchWord(State, (PUSHORT)&Offset)) + { + /* An exception occurred */ + return FALSE; + } + + /* Move the instruction pointer */ + State->InstPtr.LowWord += Offset; + } + + return TRUE; } SOFT386_OPCODE_HANDLER(Soft386OpcodeJmpAbs)