From c6a5b96796433358a32dbb175851026d58ffbf5d Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Oct 2017 11:17:53 +0200 Subject: [PATCH] fixes #244 (wrong source address display for cleared peeks) --- src/debugger/DiStella.cxx | 7 +++++++ src/emucore/M6502.ins | 20 ++++++++++---------- src/emucore/M6502.m4 | 4 ++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index a0705c6e9..c9c470185 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -120,6 +120,12 @@ void DiStella::disasm(uInt32 distart, int pass) myPC = distart - myOffset; while (myPC <= myAppData.end) { + // since -1 is used in m6502.m4 for clearing the last peek + // and this results into an access at e.g. 0xffff, + // we have to fix the consequences here (ugly!). + if(myPC == myAppData.end) + goto FIX_LAST; + if (checkBits(myPC, CartDebug::GFX | CartDebug::PGFX, CartDebug::CODE)) { if (pass == 2) @@ -137,6 +143,7 @@ void DiStella::disasm(uInt32 distart, int pass) myPC++; } else if (checkBits(myPC, CartDebug::ROW, CartDebug::CODE | CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX)) { +FIX_LAST: if (pass == 2) mark(myPC + myOffset, CartDebug::VALID_ENTRY); diff --git a/src/emucore/M6502.ins b/src/emucore/M6502.ins index 0ea0115b5..53256c733 100644 --- a/src/emucore/M6502.ins +++ b/src/emucore/M6502.ins @@ -38,7 +38,7 @@ #ifndef CLEAR_LAST_PEEK #ifdef DEBUGGER_SUPPORT - #define CLEAR_LAST_PEEK(_addr) _addr = 0; + #define CLEAR_LAST_PEEK(_addr) _addr = -1; #else #define CLEAR_LAST_PEEK(_addr) #endif @@ -428,7 +428,7 @@ case 0x7d: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); @@ -700,7 +700,7 @@ case 0x3d: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); @@ -1232,7 +1232,7 @@ case 0xdd: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); @@ -1700,7 +1700,7 @@ case 0x5d: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); @@ -2416,7 +2416,7 @@ case 0xbd: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); @@ -2646,7 +2646,7 @@ case 0xbc: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); @@ -2853,7 +2853,7 @@ case 0xfc: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); @@ -2930,7 +2930,7 @@ case 0x1d: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); @@ -3976,7 +3976,7 @@ case 0xfd: operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA); diff --git a/src/emucore/M6502.m4 b/src/emucore/M6502.m4 index 78171780c..85776530e 100644 --- a/src/emucore/M6502.m4 +++ b/src/emucore/M6502.m4 @@ -38,7 +38,7 @@ #ifndef CLEAR_LAST_PEEK #ifdef DEBUGGER_SUPPORT - #define CLEAR_LAST_PEEK(_addr) _addr = 0; + #define CLEAR_LAST_PEEK(_addr) _addr = -1; #else #define CLEAR_LAST_PEEK(_addr) #endif @@ -88,7 +88,7 @@ define(M6502_ABSOLUTEX_READ, `{ operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); - } + } else { operand = peek(intermediateAddress, DISASM_DATA);