From 7e0970d28a15e4ddedd0480f9b7484641a4d46f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Thu, 17 Nov 2016 07:36:30 +0000 Subject: [PATCH] add debug diagnostics --- BaS_gcc/x86emu/x86emu_util.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/BaS_gcc/x86emu/x86emu_util.c b/BaS_gcc/x86emu/x86emu_util.c index 9a32dbc..92637ad 100644 --- a/BaS_gcc/x86emu/x86emu_util.c +++ b/BaS_gcc/x86emu/x86emu_util.c @@ -34,6 +34,8 @@ #include "x86emu.h" #include "x86emu_regs.h" +#define DEBUG +#include "debug.h" static __inline uint16_t le16dec(const void *buf) { @@ -81,6 +83,7 @@ static uint8_t rdb(struct X86EMU *emu, uint32_t addr) { if (addr > emu->mem_size - 1) { + dbg("attempted read outside system memory: 0x%lx. Halt emulator.\r\n", addr); X86EMU_halt_sys(emu); } return emu->mem_base[addr]; @@ -100,6 +103,7 @@ static uint16_t rdw(struct X86EMU *emu, uint32_t addr) { if (addr > emu->mem_size - 2) { + dbg("attempted read outside system memory: 0x%lx. Halt emulator.\r\n", addr); X86EMU_halt_sys(emu); } return le16dec(emu->mem_base + addr); @@ -118,6 +122,7 @@ static uint32_t rdl(struct X86EMU *emu, uint32_t addr) { if (addr > emu->mem_size - 4) { + dbg("attempted read outside system memory: 0x%lx. Halt emulator.\r\n", addr); X86EMU_halt_sys(emu); } return le32dec(emu->mem_base + addr); @@ -135,6 +140,7 @@ static void wrb(struct X86EMU *emu, uint32_t addr, uint8_t val) { if (addr > emu->mem_size - 1) { + dbg("attempted write outside system memory: 0x%lx (0x%02x). Halt emulator.\r\n", addr, val); X86EMU_halt_sys(emu); } emu->mem_base[addr] = val; @@ -152,13 +158,14 @@ static void wrw(struct X86EMU *emu, uint32_t addr, uint16_t val) { if (addr > emu->mem_size - 2) { + dbg("attempted write outside system memory: 0x%lx (0x%04x). Halt emulator\r\n", addr, val); X86EMU_halt_sys(emu); } le16enc(emu->mem_base + addr, val); } /**************************************************************************** PARAMETERS: -addr - Emulator memory address to read +addr - Emulator memory address to write val - Value to store REMARKS: @@ -168,6 +175,7 @@ static void wrl(struct X86EMU *emu, uint32_t addr, uint32_t val) { if (addr > emu->mem_size - 4) { + dbg("attempted write outside system memory: 0x%lx (0x%08x)\r\n", addr, val); X86EMU_halt_sys(emu); } le32enc(emu->mem_base + addr, val);