From 1bf3afa0d059242f33062090fda80afa922a4efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Henrik=20Sk=C3=A5rstedt?= Date: Mon, 14 Dec 2015 00:27:12 -0800 Subject: [PATCH] Disassembler memory access check --- disassembler/c64.lbl | 6 +++--- disassembler/x65dsasm.cpp | 32 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/disassembler/c64.lbl b/disassembler/c64.lbl index 600272a..f49fa67 100644 --- a/disassembler/c64.lbl +++ b/disassembler/c64.lbl @@ -70,6 +70,6 @@ CIA2_TimerB_Ctrl = $dd0f data CIA2 = $dd10-$de00 data IO_Area1 = $de00-$df00 data IO_Area2 = $df00-$e000 data -Interrupt_NMI_Address = $fffa-$fffc data -Reset_Address = $fffc-$fffe data -Interrupt_Address = $fffe-$10000 data +NMIVector = $fffa-$fffc pointers vector to NMI interrupt +ResetVector = $fffc-$fffe pointers vector to reset address +IntVector = $fffe-$10000 pointers vector to interrupt address diff --git a/disassembler/x65dsasm.cpp b/disassembler/x65dsasm.cpp index a5d9181..55eb8f3 100644 --- a/disassembler/x65dsasm.cpp +++ b/disassembler/x65dsasm.cpp @@ -1379,20 +1379,22 @@ void GetReferences(unsigned char *mem, size_t bytes, bool acc_16, bool ind_16, i for (int i = 0; i(); - refs[nr].data = refs[i].data==DT_PTRS_DATA ? DT_DATA : DT_CODE; - refs[nr].pRefs->push_back(ref); - } else - refs[n].pRefs->push_back(ref); - p += 2; + if (refs[i].address>=addr && (refs[i].address+refs[i].size)<=(addr+bytes)) { + unsigned char *p = mem + refs[i].address - addr; + for (int l = 0; l(); + refs[nr].data = refs[i].data==DT_PTRS_DATA ? DT_DATA : DT_CODE; + refs[nr].pRefs->push_back(ref); + } else + refs[n].pRefs->push_back(ref); + p += 2; + } } } } @@ -1954,7 +1956,7 @@ void Disassemble(strref filename, unsigned char *mem, size_t bytes, bool acc_16, } if (addr>refs[curr_label_index].address) { if (ref.label) - out.sprintf(STRREF_FMT " = %02x\n", STRREF_ARG(ref.label), ref.address); + out.sprintf(STRREF_FMT " = $%02x\n", STRREF_ARG(ref.label), ref.address); else out.sprintf("%s_%d = $%02x\n", ref.local ? ".l" : (ref.data==DT_CODE ? "Code" : (ref.address>=0 && ref.address<0x100 ? "zp" : "Data")), ref.number, ref.address);