Author: aandrejevic
Date: Sun Sep 29 15:04:43 2013
New Revision: 60450
URL:
http://svn.reactos.org/svn/reactos?rev=60450&view=rev
Log:
[SOFT386]
Implement opcode group 0x80. Group 0x82 is just an alias to group 0x80.
Modified:
branches/ntvdm/lib/soft386/opcodes.c
branches/ntvdm/lib/soft386/opgroups.c
branches/ntvdm/lib/soft386/opgroups.h
Modified: branches/ntvdm/lib/soft386/opcodes.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opcodes.c?rev…
==============================================================================
--- branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] (original)
+++ branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] Sun Sep 29 15:04:43 2013
@@ -154,9 +154,9 @@
Soft386OpcodeShortConditionalJmp,
Soft386OpcodeShortConditionalJmp,
Soft386OpcodeShortConditionalJmp,
- Soft386OpcodeGroup80,
+ Soft386OpcodeGroup8082,
Soft386OpcodeGroup81,
- Soft386OpcodeGroup82,
+ Soft386OpcodeGroup8082,
Soft386OpcodeGroup83,
Soft386OpcodeTestByteModrm,
Soft386OpcodeTestModrm,
Modified: branches/ntvdm/lib/soft386/opgroups.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opgroups.c?re…
==============================================================================
--- branches/ntvdm/lib/soft386/opgroups.c [iso-8859-1] (original)
+++ branches/ntvdm/lib/soft386/opgroups.c [iso-8859-1] Sun Sep 29 15:04:43 2013
@@ -21,10 +21,144 @@
/* PUBLIC FUNCTIONS ***********************************************************/
-SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup80)
-{
- UNIMPLEMENTED;
- return FALSE; // TODO: NOT IMPLEMENTED
+SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup8082)
+{
+ UCHAR Immediate, Result, Dummy, Value;
+ 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;
+ }
+
+ /* Fetch the immediate operand */
+ if (!Soft386FetchByte(State, &Immediate))
+ {
+ /* Exception occurred */
+ return FALSE;
+ }
+
+ /* Read the operands */
+ if (!Soft386ReadModrmByteOperands(State, &ModRegRm, &Dummy, &Value))
+ {
+ /* Exception occurred */
+ return FALSE;
+ }
+
+ /* Check which operation is this */
+ switch (ModRegRm.Register)
+ {
+ /* ADD */
+ case 0:
+ {
+ Result = Value + Immediate;
+
+ /* Update CF, OF and AF */
+ State->Flags.Cf = (Result < Value) && (Result < Immediate);
+ State->Flags.Of = ((Value & SIGN_FLAG_BYTE) == (Immediate &
SIGN_FLAG_BYTE))
+ && ((Value & SIGN_FLAG_BYTE) != (Result &
SIGN_FLAG_BYTE));
+ State->Flags.Af = (((Value & 0x0F) + (Immediate & 0x0F)) &
0x10) ? TRUE : FALSE;
+
+ break;
+ }
+
+ /* OR */
+ case 1:
+ {
+ Result = Value | Immediate;
+ break;
+ }
+
+ /* ADC */
+ case 2:
+ {
+ INT Carry = State->Flags.Cf ? 1 : 0;
+
+ Result = Value + Immediate + Carry;
+
+ /* Update CF, OF and AF */
+ State->Flags.Cf = ((Immediate == 0xFF) && (Carry == 1))
+ || ((Result < Value) && (Result < (Immediate
+ Carry)));
+ State->Flags.Of = ((Value & SIGN_FLAG_BYTE) == (Immediate &
SIGN_FLAG_BYTE))
+ && ((Value & SIGN_FLAG_BYTE) != (Result &
SIGN_FLAG_BYTE));
+ State->Flags.Af = (((Value & 0x0F) + ((Immediate + Carry) & 0x0F))
& 0x10)
+ ? TRUE : FALSE;
+
+ break;
+ }
+
+ /* SBB */
+ case 3:
+ {
+ INT Carry = State->Flags.Cf ? 1 : 0;
+
+ Result = Value - Immediate - Carry;
+
+ /* Update CF, OF and AF */
+ State->Flags.Cf = Value < (Immediate + Carry);
+ State->Flags.Of = ((Value & SIGN_FLAG_BYTE) != (Immediate &
SIGN_FLAG_BYTE))
+ && ((Value & SIGN_FLAG_BYTE) != (Result &
SIGN_FLAG_BYTE));
+ State->Flags.Af = (Value & 0x0F) < ((Immediate + Carry) &
0x0F);
+
+ break;
+ }
+
+ /* AND */
+ case 4:
+ {
+ Result = Value & Immediate;
+ break;
+ }
+
+ /* SUB or CMP */
+ case 5:
+ case 7:
+ {
+ Result = Value - Immediate;
+
+ /* Update CF, OF and AF */
+ State->Flags.Cf = Value < Immediate;
+ State->Flags.Of = ((Value & SIGN_FLAG_BYTE) != (Immediate &
SIGN_FLAG_BYTE))
+ && ((Value & SIGN_FLAG_BYTE) != (Result &
SIGN_FLAG_BYTE));
+ State->Flags.Af = (Value & 0x0F) < (Immediate & 0x0F);
+
+ break;
+ }
+
+ /* XOR */
+ case 6:
+ {
+ Value ^= Immediate;
+ break;
+ }
+
+ default:
+ {
+ /* Shouldn't happen */
+ ASSERT(FALSE);
+ }
+ }
+
+ /* Update ZF, SF and PF */
+ State->Flags.Zf = (Result == 0) ? TRUE : FALSE;
+ State->Flags.Sf = (Result & SIGN_FLAG_BYTE) ? TRUE : FALSE;
+ State->Flags.Pf = Soft386CalculateParity(Result);
+
+ /* Unless this is CMP, write back the result */
+ if (ModRegRm.Register != 7)
+ {
+ return Soft386WriteModrmByteOperands(State, &ModRegRm, FALSE, Result);
+ }
+
+ return TRUE;
}
SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup81)
@@ -33,12 +167,6 @@
return FALSE; // TODO: NOT IMPLEMENTED
}
-SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup82)
-{
- UNIMPLEMENTED;
- return FALSE; // TODO: NOT IMPLEMENTED
-}
-
SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup83)
{
UNIMPLEMENTED;
Modified: branches/ntvdm/lib/soft386/opgroups.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opgroups.h?re…
==============================================================================
--- branches/ntvdm/lib/soft386/opgroups.h [iso-8859-1] (original)
+++ branches/ntvdm/lib/soft386/opgroups.h [iso-8859-1] Sun Sep 29 15:04:43 2013
@@ -11,9 +11,8 @@
/* DEFINES ********************************************************************/
-SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup80);
+SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup8082);
SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup81);
-SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup82);
SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup83);
SOFT386_OPCODE_HANDLER(Soft386OpcodeGroup8F);
SOFT386_OPCODE_HANDLER(Soft386OpcodeGroupC0);