[SOFT386]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sun, 1 Sep 2013 16:19:29 +0000 (16:19 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sun, 1 Sep 2013 16:19:29 +0000 (16:19 +0000)
Implement the opcodes for MOV reg16/32, imm16/32

svn path=/branches/ntvdm/; revision=59949

lib/soft386/opcodes.c
lib/soft386/opcodes.h

index 0aa22fd..95c7398 100644 (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;
+}
index 8a560e9..ec03017 100644 (file)
@@ -191,4 +191,12 @@ Soft386OpcodeShortJump
     UCHAR Opcode
 );
 
+BOOLEAN
+FASTCALL
+Soft386OpcodeMovRegImm
+(
+    PSOFT386_STATE State,
+    UCHAR Opcode
+);
+
 #endif // _OPCODES_H_