From 179627bf406ea8123c6e59f39e2af1e71baffcdd Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sun, 1 Sep 2013 16:19:29 +0000 Subject: [PATCH] [SOFT386] Implement the opcodes for MOV reg16/32, imm16/32 svn path=/branches/ntvdm/; revision=59949 --- lib/soft386/opcodes.c | 69 ++++++++++++++++++++++++++++++++++++++----- lib/soft386/opcodes.h | 8 +++++ 2 files changed, 69 insertions(+), 8 deletions(-) diff --git a/lib/soft386/opcodes.c b/lib/soft386/opcodes.c index 0aa22fd6efd..95c7398bac3 100644 --- a/lib/soft386/opcodes.c +++ b/lib/soft386/opcodes.c @@ -208,14 +208,14 @@ Soft386OpcodeHandlers[SOFT386_NUM_OPCODE_HANDLERS] = NULL, // TODO: OPCODE 0xB5 NOT SUPPORTED NULL, // TODO: OPCODE 0xB6 NOT SUPPORTED NULL, // TODO: OPCODE 0xB7 NOT SUPPORTED - NULL, // TODO: OPCODE 0xB8 NOT SUPPORTED - NULL, // TODO: OPCODE 0xB9 NOT SUPPORTED - NULL, // TODO: OPCODE 0xBA NOT SUPPORTED - NULL, // TODO: OPCODE 0xBB NOT SUPPORTED - NULL, // TODO: OPCODE 0xBC NOT SUPPORTED - NULL, // TODO: OPCODE 0xBD NOT SUPPORTED - NULL, // TODO: OPCODE 0xBE NOT SUPPORTED - NULL, // TODO: OPCODE 0xBF NOT SUPPORTED + Soft386OpcodeMovRegImm, + Soft386OpcodeMovRegImm, + Soft386OpcodeMovRegImm, + Soft386OpcodeMovRegImm, + Soft386OpcodeMovRegImm, + Soft386OpcodeMovRegImm, + Soft386OpcodeMovRegImm, + Soft386OpcodeMovRegImm, NULL, // TODO: OPCODE 0xC0 NOT SUPPORTED NULL, // TODO: OPCODE 0xC1 NOT SUPPORTED NULL, // TODO: OPCODE 0xC2 NOT SUPPORTED @@ -1168,3 +1168,56 @@ Soft386OpcodeShortJump(PSOFT386_STATE State, UCHAR Opcode) return TRUE; } + +BOOLEAN +FASTCALL +Soft386OpcodeMovRegImm(PSOFT386_STATE State, UCHAR Opcode) +{ + BOOLEAN Size = State->SegmentRegs[SOFT386_REG_CS].Size; + + /* Make sure this is the right instruction */ + ASSERT((Opcode & 0xF8) == 0xB8); + + 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) + { + ULONG Value; + + /* Fetch the dword */ + if (!Soft386FetchDword(State, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Store the value in the register */ + State->GeneralRegs[Opcode & 0x07].Long = Value; + } + else + { + USHORT Value; + + /* Fetch the word */ + if (!Soft386FetchWord(State, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Store the value in the register */ + State->GeneralRegs[Opcode & 0x07].LowWord = Value; + } + + return TRUE; +} diff --git a/lib/soft386/opcodes.h b/lib/soft386/opcodes.h index 8a560e97bab..ec030171a07 100644 --- a/lib/soft386/opcodes.h +++ b/lib/soft386/opcodes.h @@ -191,4 +191,12 @@ Soft386OpcodeShortJump UCHAR Opcode ); +BOOLEAN +FASTCALL +Soft386OpcodeMovRegImm +( + PSOFT386_STATE State, + UCHAR Opcode +); + #endif // _OPCODES_H_