[SOFT386]

Implement the opcodes for MOV reg16/32, imm16/32


svn path=/branches/ntvdm/; revision=59949
This commit is contained in:
Aleksandar Andrejevic 2013-09-01 16:19:29 +00:00
parent 50e90be14b
commit 179627bf40
2 changed files with 69 additions and 8 deletions

View file

@ -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;
}

View file

@ -191,4 +191,12 @@ Soft386OpcodeShortJump
UCHAR Opcode
);
BOOLEAN
FASTCALL
Soft386OpcodeMovRegImm
(
PSOFT386_STATE State,
UCHAR Opcode
);
#endif // _OPCODES_H_