[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Tue, 2 Jul 2013 21:40:11 +0000 (21:40 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Tue, 2 Jul 2013 21:40:11 +0000 (21:40 +0000)
Add more debug output.
[SOFTX86]
Properly set the carry and overflow flags.

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

lib/3rdparty/softx86/softx86/add.c
subsystems/ntvdm/bios.c
subsystems/ntvdm/emulator.c
subsystems/ntvdm/ntvdm.c

index 1ea1549..6279c8f 100644 (file)
@@ -386,13 +386,13 @@ sx86_uword op_sub16(softx86_ctx* ctx,sx86_uword src,sx86_uword val)
 /* peform the addition */
        ret = src - val;
 
-/* if carry/overflow */
-       if (ret > src)
-               ctx->state->reg_flags.val |=
-                        (SX86_CPUFLAG_CARRY | SX86_CPUFLAG_OVERFLOW);
-       else
-               ctx->state->reg_flags.val &=
-                       ~(SX86_CPUFLAG_CARRY | SX86_CPUFLAG_OVERFLOW);
+/* if carry */
+        if (val > src) ctx->state->reg_flags.val |= SX86_CPUFLAG_CARRY;
+        else ctx->state->reg_flags.val &= ~SX86_CPUFLAG_CARRY;
+
+/* if overflow */
+       if ((ret & 0x8000) != (src & 0x8000)) ctx->state->reg_flags.val |= SX86_CPUFLAG_OVERFLOW;
+       else ctx->state->reg_flags.val &= ~SX86_CPUFLAG_OVERFLOW;
 
 /* if result treated as signed value is negative */
        if (ret & 0x8000)       ctx->state->reg_flags.val |=  SX86_CPUFLAG_SIGN;
index 5a796cf..1270be2 100644 (file)
@@ -369,6 +369,12 @@ VOID BiosVideoService()
         {
             break;
         }
+
+        default:
+        {
+            DPRINT1("BIOS Function INT 10h, AH = 0x%02X NOT IMPLEMENTED\n",
+                    HIBYTE(Eax));
+        }
     }
 }
 
@@ -404,6 +410,12 @@ VOID BiosKeyboardService()
 
             break;
         }
+        
+        default:
+        {
+            DPRINT1("BIOS Function INT 16h, AH = 0x%02X NOT IMPLEMENTED\n",
+                    HIBYTE(Eax));
+        }
     }
 }
 
@@ -442,6 +454,12 @@ VOID BiosTimeService()
 
             break;
         }
+
+        default:
+        {
+            DPRINT1("BIOS Function INT 1Ah, AH = 0x%02X NOT IMPLEMENTED\n",
+                    HIBYTE(Eax));
+        }
     }
 }
 
index a502dda..7c7513b 100644 (file)
@@ -385,6 +385,11 @@ VOID EmulatorClearFlag(ULONG Flag)
 
 VOID EmulatorStep()
 {
+    /* Print the current position - useful for debugging */
+    DPRINT("Executing at CS:IP = %04X:%04X\n",
+           EmulatorGetRegister(EMULATOR_REG_CS),
+           EmulatorContext.state->reg_ip);
+
     /* Call the softx86 API */
     if (!softx86_step(&EmulatorContext))
     {
index 351352a..f3ea8b0 100644 (file)
@@ -69,7 +69,10 @@ INT wmain(INT argc, WCHAR *argv[])
 {
     INT i;
     CHAR CommandLine[128];
-    DWORD CurrentTickCount, LastTickCount = 0, Cycles = 0, LastCyclePrintout = 0;
+    DWORD CurrentTickCount;
+    DWORD LastTickCount = GetTickCount();
+    DWORD Cycles = 0;
+    DWORD LastCyclePrintout = GetTickCount();
     LARGE_INTEGER Frequency, LastTimerTick, Counter;
     LONGLONG TimerTicks;
 
@@ -79,7 +82,11 @@ INT wmain(INT argc, WCHAR *argv[])
     /* The DOS command line must be ASCII */
     WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, 128, NULL, NULL);
 
-    if (!EmulatorInitialize()) return 1;
+    if (!EmulatorInitialize())
+    {
+        wprintf(L"FATAL: Failed to initialize the CPU emulator\n");
+        return 1;
+    }
     
     /* Initialize the performance counter (needed for hardware timers) */
     if (!QueryPerformanceFrequency(&Frequency))