From c4ef9b6f44ae534600957031f5133f6134e08598 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Tue, 2 Jul 2013 21:40:11 +0000 Subject: [PATCH] [NTVDM] Add more debug output. [SOFTX86] Properly set the carry and overflow flags. svn path=/branches/ntvdm/; revision=59410 --- lib/3rdparty/softx86/softx86/add.c | 14 +++++++------- subsystems/ntvdm/bios.c | 18 ++++++++++++++++++ subsystems/ntvdm/emulator.c | 5 +++++ subsystems/ntvdm/ntvdm.c | 11 +++++++++-- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/lib/3rdparty/softx86/softx86/add.c b/lib/3rdparty/softx86/softx86/add.c index 1ea154969cc..6279c8f449a 100644 --- a/lib/3rdparty/softx86/softx86/add.c +++ b/lib/3rdparty/softx86/softx86/add.c @@ -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; diff --git a/subsystems/ntvdm/bios.c b/subsystems/ntvdm/bios.c index 5a796cf24dd..1270be26844 100644 --- a/subsystems/ntvdm/bios.c +++ b/subsystems/ntvdm/bios.c @@ -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)); + } } } diff --git a/subsystems/ntvdm/emulator.c b/subsystems/ntvdm/emulator.c index a502dda33d5..7c7513bbf09 100644 --- a/subsystems/ntvdm/emulator.c +++ b/subsystems/ntvdm/emulator.c @@ -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)) { diff --git a/subsystems/ntvdm/ntvdm.c b/subsystems/ntvdm/ntvdm.c index 351352aa96c..f3ea8b009f9 100644 --- a/subsystems/ntvdm/ntvdm.c +++ b/subsystems/ntvdm/ntvdm.c @@ -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))