- [NEW] While debugging you can go back/forward in time

- [NEW] Step by step execution with F6
- [NEW] Memory is tagged as code or data while executing, so later it can be properly disassembled
- [NEW] "reg X value" to set the value of X register
- [FIX] IX opcode table had errors
- [FIX] opcodes with two parameters where printed incorrectly on the disassembler
- [FIX] opcodes can't be lager than 4 bytes
- [CHG] Berserk mode and fernando martin TAP by default, to help with debugging
This commit is contained in:
2024-12-05 17:28:10 +01:00
parent cce38449a5
commit c0f9fa9933
7 changed files with 129 additions and 17 deletions

View File

@@ -7,6 +7,13 @@
#include "ui.h"
namespace z80debug
{
namespace history
{
uint16_t buffer[65536];
uint8_t top=0;
uint8_t pos=0;
}
uint16_t oAF, oBC, oDE, oHL, oAF2, oBC2, oDE2, oHL2, oIX, oIY, oSP, oPC;
bool mem_modified[65536];
@@ -84,17 +91,24 @@ namespace z80debug
uint16_t find_previous_opcode(uint16_t pc)
{
pc-=4;
if (z80dis::getOpcodeSize(pc) != 4) {
pc++;
if (z80dis::getOpcodeSize(pc) != 3) {
pc++;
if (z80dis::getOpcodeSize(pc) != 2) {
pc++;
}
}
}
pc--;
if (z80::getMemTag(pc)!=MEMTAG_CODE && z80::getMemTag(pc)!=MEMTAG_INST) return pc;
while (z80::getMemTag(pc)!=MEMTAG_INST) pc--;
return pc;
/*
pc-=4;
if (z80dis::getOpcodeSize(pc) == 4) return pc;
if (z80dis::getOpcodeSize(pc) == 3) return pc+3;
pc++;
if (z80dis::getOpcodeSize(pc) == 3) return pc;
if (z80dis::getOpcodeSize(pc) == 2) return pc+2;
pc++;
if (z80dis::getOpcodeSize(pc) == 2) return pc;
return pc+1;
*/
}
void refresh()
@@ -144,8 +158,13 @@ namespace z80debug
pos = find_previous_opcode(pos);
if (breakpoints[pos]&9) ui::printtxt(0,i,"*", COLOR_RED);
ui::printtxt(1,i,tohex(pos,4), COLOR_CYAN);
ui::printtxt(7,i, z80dis::getOpcode(pos), COLOR_GRAY);
ui::printtxt(19,i, z80dis::getAsm(pos), COLOR_WHITE);
if (z80::getMemTag(pos)==MEMTAG_INST) {
ui::printtxt(7,i, z80dis::getOpcode(pos), COLOR_GRAY);
ui::printtxt(19,i, z80dis::getAsm(pos), COLOR_WHITE);
} else {
ui::printtxt(7,i, tohex(z80::getMem()[pos],2), COLOR_GRAY);
ui::printtxt(19,i, "?????????", COLOR_GRAY);
}
}
//for (int i=0;i<20;++i) printtxt(1,i,tohex(pc,4), COLOR_CYAN);
@@ -420,6 +439,17 @@ namespace z80debug
uint8_t *mem = z80::getMem();
int value = mem[address];
SDL_itoa(value, console_error, 10);
} else if (strcmp(cmd, "reg")==0) {
getcmd();
if (strcmp(cmd, "f")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[0] = value; }
else if (strcmp(cmd, "a")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[1] = value; }
else if (strcmp(cmd, "c")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[2] = value; }
else if (strcmp(cmd, "b")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[3] = value; }
else if (strcmp(cmd, "e")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[4] = value; }
else if (strcmp(cmd, "d")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[5] = value; }
else if (strcmp(cmd, "l")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[6] = value; }
else if (strcmp(cmd, "h")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[7] = value; }
else { strcpy(console_error, "Syntax error: invalid register"); return; }
}
}
@@ -476,4 +506,33 @@ namespace z80debug
fread(&memory[16*1024], 48*1024, 1, f);
fclose(f);
}
namespace history
{
void store()
{
buffer[++top] = z80::getPC();
pos=top;
}
void gototop()
{
pos = top;
z80::setPC(buffer[pos]);
}
void goforward()
{
if (pos == top) return;
z80::setPC(buffer[++pos]);
}
void goback()
{
if (uint8_t(pos-1) == top) return;
z80::setPC(buffer[--pos]);
}
}
}