- [NEW] Més opcions de control del etiquetat de la memòria

- [FIX] Les instruccions DD34 i DD35 no pillaven un byte signed, sino unsigned. Han de haber-ne més. REPASAR.
- [ONGOING] Preparant el analyzer per a tindre diverses visualitzacions de la memòria
- [NEW] El debugger ara mostra el etiquetat de la memòria en el desensamblador
- [FIX] El cursor ja se torna a vore en el debugger
This commit is contained in:
2024-12-13 13:52:41 +01:00
parent 8c197d5519
commit c9aceeb387
4 changed files with 68 additions and 13 deletions

53
z80.cpp
View File

@@ -144,24 +144,48 @@ namespace z80
#define EX(a,b) {auto temp=a;a=b;b=temp;}
uint8_t READ_MEM_8(const uint16_t addr)
bool reading_m1 = false;
uint8_t READ_MEM_8(const uint16_t addr, const bool code=false)
{
if (z80debug::isbreak(addr, 2)) z80debug::stop();
t+=3;
memtag[addr] = MEMTAG_DATA;
if (memtag[addr] != MEMTAG_IGNORE) {
if (!code) {
if ( memtag[addr] == MEMTAG_INST ) {
printf("WARNING! READING DATA FROM CODE!!! $%4X\n", addr);
z80debug::stop();
} else {
memtag[addr] = MEMTAG_DATA;
}
} else {
if ( (reading_m1) && (memtag[addr] == MEMTAG_DATA) ) {
printf("WARNING! EXECUTING DATA AS CODE!!! $%4X\n", addr);
z80debug::stop();
}
}
}
reading_m1 = false;
return memory[addr];
}
uint8_t READ_MEM_8()
{
uint8_t data = READ_MEM_8(rPC);
memtag[rPC++] = MEMTAG_CODE;
uint8_t data = READ_MEM_8(rPC, true);
if ( (memtag[rPC] != MEMTAG_IGNORE) && (memtag[rPC] != MEMTAG_MIXED) ) {
if (memtag[rPC] == MEMTAG_DATA)
memtag[rPC] = MEMTAG_MIXED;
else
memtag[rPC] = MEMTAG_CODE;
}
rPC++;
return data;
}
uint8_t READ_M1()
{
t+=1;
reading_m1 = true;
return READ_MEM_8();
}
@@ -184,7 +208,16 @@ namespace z80
if (z80debug::isbreak(addr, 4)) z80debug::stop();
//if (z80debug::debugging())
z80debug::setmemmodified(addr);
memtag[addr] = MEMTAG_DATA;
if ( (memtag[addr] != MEMTAG_IGNORE) && (memtag[addr] != MEMTAG_MIXED) ) {
if (memtag[addr]==MEMTAG_INST) {
printf("WARNING! WRITING DATA OVER CODE!!! $%4X\n", addr);
z80debug::stop();
} else if (memtag[addr] == MEMTAG_CODE) {
memtag[addr] = MEMTAG_MIXED;
} else {
memtag[addr] = MEMTAG_DATA;
}
}
return value;
}
@@ -1082,7 +1115,7 @@ namespace z80
current_opcode_address = rPC;
t = 0;
const uint8_t opcode = READ_M1();
memtag[current_opcode_address] = MEMTAG_INST;
if (memtag[current_opcode_address] != MEMTAG_IGNORE) memtag[current_opcode_address] = MEMTAG_INST;
memtouched[current_opcode_address] = memtouched[current_opcode_address] != MEMTAG_NONE ? MEMTAG_REPEAT : MEMTAG_INST;
uint16_t tmp;
@@ -1717,8 +1750,8 @@ namespace z80
case 0x31: INVALID(opcode); break;
case 0x32: INVALID(opcode); break;
case 0x33: INVALID(opcode); break;
case 0x34: INCMEM8(rIX+READ_MEM_8());t+=2; break;
case 0x35: DECMEM8(rIX+READ_MEM_8());t+=2; break;
case 0x34: d=READ_MEM_8(); INCMEM8(rIX+d);t+=2; break;
case 0x35: d=READ_MEM_8(); DECMEM8(rIX+d);t+=2; break;
case 0x36: d=READ_MEM_8(); WRITE_MEM_8(rIX+d, READ_MEM_8()); t+=2; break;
case 0x37: INVALID(opcode); break;
case 0x38: INVALID(opcode); break;
@@ -2768,7 +2801,9 @@ namespace z80
void setPC(const uint16_t addr) { rPC = addr; }
uint8_t getMemTag(const uint16_t addr) { return memtag[addr]; };
uint8_t getMemTag(const uint16_t addr) { return memtag[addr]; }
void setMemTag(const uint16_t addr, const uint8_t value) { memtag[addr] = value; }
void clearMemTag()
{