diff --git a/lib/soft386/opgroups.c b/lib/soft386/opgroups.c index c228b2920f0..f011303ec17 100644 --- a/lib/soft386/opgroups.c +++ b/lib/soft386/opgroups.c @@ -243,14 +243,106 @@ SOFT386_OPCODE_HANDLER(Soft386OpcodeGroupC1) SOFT386_OPCODE_HANDLER(Soft386OpcodeGroupC6) { - UNIMPLEMENTED; - return FALSE; // TODO: NOT IMPLEMENTED + UCHAR Immediate; + SOFT386_MOD_REG_RM ModRegRm; + BOOLEAN AddressSize = State->SegmentRegs[SOFT386_REG_CS].Size; + + if (State->PrefixFlags & SOFT386_PREFIX_ADSIZE) + { + /* The ADSIZE prefix toggles the size */ + AddressSize = !AddressSize; + } + + if (!Soft386ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + if (ModRegRm.Register != 0) + { + /* Invalid */ + Soft386Exception(State, SOFT386_EXCEPTION_UD); + return FALSE; + } + + /* Get the immediate operand */ + if (!Soft386FetchByte(State, &Immediate)) + { + /* Exception occurred */ + return FALSE; + } + + return Soft386WriteModrmByteOperands(State, + &ModRegRm, + FALSE, + Immediate); } SOFT386_OPCODE_HANDLER(Soft386OpcodeGroupC7) { - UNIMPLEMENTED; - return FALSE; // TODO: NOT IMPLEMENTED + SOFT386_MOD_REG_RM ModRegRm; + BOOLEAN OperandSize, AddressSize; + + OperandSize = AddressSize = State->SegmentRegs[SOFT386_REG_CS].Size; + + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + OperandSize = !OperandSize; + } + + if (State->PrefixFlags & SOFT386_PREFIX_ADSIZE) + { + /* The ADSIZE prefix toggles the size */ + AddressSize = !AddressSize; + } + + if (!Soft386ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + if (ModRegRm.Register != 0) + { + /* Invalid */ + Soft386Exception(State, SOFT386_EXCEPTION_UD); + return FALSE; + } + + if (OperandSize) + { + ULONG Immediate; + + /* Get the immediate operand */ + if (!Soft386FetchDword(State, &Immediate)) + { + /* Exception occurred */ + return FALSE; + } + + return Soft386WriteModrmDwordOperands(State, + &ModRegRm, + FALSE, + Immediate); + } + else + { + USHORT Immediate; + + /* Get the immediate operand */ + if (!Soft386FetchWord(State, &Immediate)) + { + /* Exception occurred */ + return FALSE; + } + + return Soft386WriteModrmWordOperands(State, + &ModRegRm, + FALSE, + Immediate); + } } SOFT386_OPCODE_HANDLER(Soft386OpcodeGroupD0)