- [NEW] Configuració per a compilar i depurar des de vscode
- [FIX] Meimades per a que es calle el compilaor al dir-li -Wall - [NEW] Reestructurats els simbols, 6502dis probablement acabe desapareguent - [NEW] Reactivats els breakpoints i next (pas a pas sense entrar en subrutines) - [NEW] Nou motor de desensamblat - [NEW] Ja es mostren tots els simbols en el desensamblat - [NEW] Syntax colorets en el desensamblat
This commit is contained in:
+79
-17
@@ -269,8 +269,8 @@ namespace m6502debugger
|
||||
|
||||
if (chrx>=midx+2 && chry>=sym_y+1) {
|
||||
const int line = chry-(sym_y+1);
|
||||
if (line<m6502dis::getNumSymbols()) {
|
||||
cursor = m6502dis::getSymbolAddress(line);
|
||||
if (line<m6502dis::symbols::count()) {
|
||||
cursor = m6502dis::symbols::address(line);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
@@ -312,6 +312,12 @@ namespace m6502debugger
|
||||
|
||||
setcursor(address);
|
||||
history::store();
|
||||
|
||||
if (!atari2600::is_paused() && isbreak(address, BREAKPOINT_EXECUTE | BREAKPOINT_NEXT)) {
|
||||
atari2600::pause();
|
||||
m6502debugger::show();
|
||||
breakpoints[address] = breakpoints[address] & ~BREAKPOINT_NEXT;
|
||||
}
|
||||
}
|
||||
|
||||
void onMemRead(uint16_t address, bool code)
|
||||
@@ -434,13 +440,67 @@ namespace m6502debugger
|
||||
//return pc;
|
||||
}
|
||||
|
||||
void printAssemblerLine(const uint16_t address, const int line, const bool confirmed)
|
||||
{
|
||||
uint8_t column = 31;
|
||||
uint8_t colors[4] = {COLOR_PURPLE, COLOR_TEAL, COLOR_GRAY, COLOR_ORANGE};
|
||||
if (confirmed) for (int i=0; i<4; ++i) colors[i] += 8; //{COLOR_MAGENTA, COLOR_BLUE, COLOR_WHITE, COLOR_YELLOW};
|
||||
m6502::opcodes::opcodeProperties op = m6502::opcodes::opcodeDescriptors[mem::read(address)];
|
||||
const char *opcode_name = m6502::opcodes::instructions[op.instr].name;
|
||||
ui::printtxt(column,line, opcode_name, colors[0]);
|
||||
column += strlen(opcode_name)+1;
|
||||
const char *opcode_prefix = m6502::opcodes::addressingModes[op.addrMode].preText;
|
||||
const char *opcode_postfix = m6502::opcodes::addressingModes[op.addrMode].postText;
|
||||
if (strlen(opcode_prefix)>0) {
|
||||
ui::printtxt(column,line, opcode_prefix, colors[1]);
|
||||
column += strlen(opcode_prefix);
|
||||
}
|
||||
|
||||
char buffer[256];
|
||||
uint16_t value = 0;
|
||||
const uint8_t len = m6502::opcodes::addressingModes[op.addrMode].length;
|
||||
if (len>1) {
|
||||
value = mem::read(address+1);
|
||||
if (len>2) value |= (mem::read(address+2) << 8);
|
||||
|
||||
if (op.addrMode != m6502::opcodes::amImmediate && op.addrMode != m6502::opcodes::amRelative &&
|
||||
( m6502::opcodes::instructions[op.instr].group == m6502::opcodes::fgLoadStore || m6502::opcodes::instructions[op.instr].group == m6502::opcodes::fgJumpCall )) {
|
||||
if (m6502dis::symbols::get(value)[0]!=0) {
|
||||
sprintf(buffer, "%s", m6502dis::symbols::get(value));
|
||||
ui::printtxt(column,line, buffer, colors[2]);
|
||||
column += strlen(buffer);
|
||||
}
|
||||
}
|
||||
if (buffer[0] == 0) {
|
||||
if (len==3) {
|
||||
value |= (mem::read(address+2) << 8);
|
||||
sprintf(buffer, "$%04x", value);
|
||||
} else if (len==2) {
|
||||
if (op.addrMode == m6502::opcodes::amRelative) {
|
||||
sprintf(buffer, "%hhd", value);
|
||||
} else {
|
||||
sprintf(buffer, "$%02x", value);
|
||||
}
|
||||
}
|
||||
ui::printtxt(column,line, buffer, colors[3]);
|
||||
column += strlen(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(opcode_postfix)>0) {
|
||||
ui::printtxt(column,line, opcode_postfix, colors[1]);
|
||||
//column += strlen(opcode_prefix);
|
||||
}
|
||||
}
|
||||
|
||||
void printDissasemblerLine(const uint16_t address, const int line, const bool heuristics=false)
|
||||
{
|
||||
const bool isMemory = mem::debug::getInfo(address).memType & mdtMemory;
|
||||
bool isConfirmedInstruction = true;
|
||||
|
||||
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_WHITE, COLOR_WHITE};
|
||||
const uint8_t tag = tags[address];
|
||||
if ( !(tag & (MEMTAG_TINST | MEMTAG_TREPEAT)) ) colors[3]=COLOR_GRAY;
|
||||
if ( !(tag & (MEMTAG_TINST | MEMTAG_TREPEAT)) ) { colors[3]=COLOR_GRAY; isConfirmedInstruction = false; }
|
||||
if ( !(tag & MEMTAG_TOUCHED) ) colors[1]=COLOR_GRAY;
|
||||
|
||||
if (atari2600::is_paused() && (address == m6502::getPC())) {
|
||||
@@ -454,7 +514,7 @@ namespace m6502debugger
|
||||
if (!isMemory) return;
|
||||
|
||||
if ( (tag & MEMTAG_INST) || heuristics ) {
|
||||
const char *sym = m6502dis::getSymbol(address);
|
||||
const char *sym = m6502dis::symbols::get(address);
|
||||
if (sym[0]!=0) ui::printtxt(7,line, sym, COLOR_YELLOW);
|
||||
|
||||
const int opcodesize = m6502dis::getOpcodeSize(address);
|
||||
@@ -465,7 +525,8 @@ namespace m6502debugger
|
||||
}
|
||||
|
||||
ui::printtxt(19,line, m6502dis::getOpcode(address), colors[2]);
|
||||
ui::printtxt(31,line, m6502dis::getAsm(address), colors[3]);
|
||||
//ui::printtxt(31,line, m6502dis::getAsm(address), colors[3]);
|
||||
printAssemblerLine(address, line, isConfirmedInstruction);
|
||||
} else {
|
||||
ui::printrect(19,line,2,1,COLOR_GRAY);
|
||||
ui::printtxt(19,line, tohex(mem::read(address),2), COLOR_WHITE);
|
||||
@@ -719,18 +780,18 @@ namespace m6502debugger
|
||||
ui::printtxt(midx+3,sym_y, "SYMBOLS:", COLOR_WHITE);
|
||||
|
||||
ui::setoffset(midx+1, sym_y+1);
|
||||
const int num_symbols = m6502dis::getNumSymbols();
|
||||
const int num_symbols = m6502dis::symbols::count();
|
||||
for (int i=0;i<num_symbols;++i) {
|
||||
if (i>=sym_h-2) break;
|
||||
uint8_t colors[2] = {COLOR_GRAY, COLOR_WHITE};
|
||||
const uint16_t address = m6502dis::getSymbolAddress(i);
|
||||
const uint16_t address = m6502dis::symbols::address(i);
|
||||
if (address==cursor) {
|
||||
ui::printrect(0,line,23,1,COLOR_BLUE);
|
||||
colors[0]=colors[1]=COLOR_YELLOW;
|
||||
}
|
||||
|
||||
ui::printtxt(1, i, tohex(address,4), colors[0]);
|
||||
ui::printtxt(6, i, m6502dis::getSymbol(address), colors[1]);
|
||||
ui::printtxt(6, i, m6502dis::symbols::get(address), colors[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -864,11 +925,11 @@ namespace m6502debugger
|
||||
uint8_t break_type = 1;
|
||||
if (cmd[0]!=0) {
|
||||
if (strcmp(cmd, "x")==0 || strcmp(cmd, "exec")==0) {
|
||||
break_type = 1;
|
||||
break_type = BREAKPOINT_EXECUTE;
|
||||
} else if (strcmp(cmd, "r")==0 || strcmp(cmd, "read")==0) {
|
||||
break_type = 2;
|
||||
break_type = BREAKPOINT_READ;
|
||||
} else if (strcmp(cmd, "w")==0 || strcmp(cmd, "write")==0) {
|
||||
break_type = 4;
|
||||
break_type = BREAKPOINT_WRITE;
|
||||
} else {
|
||||
sendToConsoleLog("Illegal break type");
|
||||
return;
|
||||
@@ -955,19 +1016,19 @@ namespace m6502debugger
|
||||
char tmp[12]; strcpy(tmp, cmd);
|
||||
getcmd();
|
||||
if (cmd[0]==0) {
|
||||
m6502dis::setSymbol(m6502::getPC(), tmp);
|
||||
m6502dis::symbols::set(m6502::getPC(), tmp);
|
||||
} else {
|
||||
int value = getnum(cmd);
|
||||
m6502dis::setSymbol(value, tmp);
|
||||
m6502dis::symbols::set(value, tmp);
|
||||
}
|
||||
sendToConsoleLog("Symbol added");
|
||||
} else if (strcmp(cmd, "del")==0) {
|
||||
getcmd();
|
||||
if (cmd[0]==0) {
|
||||
m6502dis::setSymbol(m6502::getPC(), NULL);
|
||||
m6502dis::symbols::set(m6502::getPC(), NULL);
|
||||
} else {
|
||||
int value = getnum(cmd);
|
||||
m6502dis::setSymbol(value, NULL);
|
||||
m6502dis::symbols::set(value, NULL);
|
||||
}
|
||||
sendToConsoleLog("Symbol removed");
|
||||
}
|
||||
@@ -1025,9 +1086,10 @@ namespace m6502debugger
|
||||
|
||||
uint32_t next()
|
||||
{
|
||||
breakpoints[m6502::getPC()+m6502dis::getOpcodeSize(m6502::getPC())] |= 8;
|
||||
breakpoints[m6502::getPC()+m6502dis::getOpcodeSize(m6502::getPC())] |= BREAKPOINT_NEXT;
|
||||
//const uint32_t t = m6502::step();
|
||||
cont();
|
||||
atari2600::resume();
|
||||
//cont();
|
||||
return 0; //t;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user