Cleaned up disassembler code a bit. Added a few new labels for disassembler viewer zero page addresses.

This commit is contained in:
mlong 2021-01-26 11:57:36 -06:00
parent e301ca49d0
commit 46f9ceb386
3 changed files with 46 additions and 56 deletions

View File

@ -20,30 +20,14 @@ QList<DisassembledItem> Disassembler::disassemble(quint16 from, quint16 to,
m_to = to; m_to = to;
QList<DisassembledItem> retval; QList<DisassembledItem> retval;
qDebug() << "\n\n*****************\n\nDisassemble: From"<<uint16ToHex(from)<<"to"<<uint16ToHex(to); qDebug() << "\n\n*****************\n\nDisassemble: From"<<uint16ToHex(from)<<"to"<<uint16ToHex(to);
//#define OLDDISSEM
#ifdef OLDDISSEM MemoryUsageMap memUse;
for (int idx = from; idx <= to; )
{
DisassembledItem item;
disassembleOp(quint16(idx),item);
retval.append(item);
idx = item.nextContiguousAddress();
if (idx > 0xffff || (idx < from)) {
qDebug() << "Breaking.";
break;
}
}
#else
MemoryUsageMap memuse;
bool stopping = false; bool stopping = false;
quint16 next = from; quint16 next = from;
while (entryPoints.count()) while (entryPoints.count())
{ {
next = entryPoints.takeFirst(); next = entryPoints.takeFirst();
//m_jumps.append(entryPoints);
m_stack.push(next); m_stack.push(next);
} }
@ -55,7 +39,7 @@ QList<DisassembledItem> Disassembler::disassemble(quint16 from, quint16 to,
bool ok = false; bool ok = false;
if (next >= from && next <= to) //TODO: Remove this to not limit disassembly to program range if (next >= from && next <= to) //TODO: Remove this to not limit disassembly to program range
ok = disassembleOp(next,item,&memuse); ok = disassembleOp(next,item,&memUse);
if (ok) if (ok)
{ {
@ -67,24 +51,15 @@ QList<DisassembledItem> Disassembler::disassemble(quint16 from, quint16 to,
{ {
qDebug() << "Is Branch"; qDebug() << "Is Branch";
m_stack.push(item.targetAddress()); m_stack.push(item.targetAddress());
// if (!m_jumps.contains(item.targetAddress()))
// {
// m_jumps.append(item.targetAddress());
// qDebug() << "Appending branch" << uint16ToHex(item.targetAddress()) << "to jump table";
// }
} }
if (item.isJsr() && !item.canNotFollow()) if (item.isJsr() && !item.canNotFollow())
{ {
if (item.targetAddress() <= to) //TODO: Remove this to not limit disassembly to program range if (item.targetAddress() <= to && item.targetAddress() >= from) //TODO: Remove this to not limit disassembly to program range
{ {
if (m_stack.push(item.targetAddress())) if (m_stack.push(item.targetAddress()))
//if (!m_jumps.contains(item.targetAddress()))
{ {
qDebug() << "Appending" << uint16ToHex(item.targetAddress()) << "to jump table"; qDebug() << "Appending" << uint16ToHex(item.targetAddress()) << "to jump table";
//m_jumps.append(item.targetAddress());
} }
else else
{ {
@ -105,23 +80,14 @@ QList<DisassembledItem> Disassembler::disassemble(quint16 from, quint16 to,
stopping = true; // already processed this address stopping = true; // already processed this address
} }
// if (found.contains(next)) stopping = true;
if (next >= to) stopping = true; if (next >= to) stopping = true;
// if (stopping) {
// qDebug() << "Stopping. Stops processing: "
// << item.stopsProcessing()
// << ", next>=to: " << (next >= to)
// << ", alreadyFound: " << ((!ok)?"true":"false");
// }
} }
m_memusagemap.merge(memuse); m_memusagemap.merge(memUse);
if (processRecursively) if (processRecursively)
//while (m_jumps.size())
while (!m_stack.isEmpty()) while (!m_stack.isEmpty())
{ {
// quint16 num = m_jumps.takeFirst();
quint16 num = m_stack.pop(); quint16 num = m_stack.pop();
if (!m_memusagemap[num].testFlag(Operation)) if (!m_memusagemap[num].testFlag(Operation))
{ {
@ -134,27 +100,10 @@ QList<DisassembledItem> Disassembler::disassemble(quint16 from, quint16 to,
} }
} }
#endif
// qSort(retval);
std::sort(retval.begin(),retval.end()); std::sort(retval.begin(),retval.end());
// QStringList hexdump;
// foreach (quint16 adr,m_memusagemap.addressesWhichContain(Operation))
// {
// hexdump.append(uint16ToHex(adr));
// }
// qDebug() << "Operations:" << hexdump;
// hexdump.clear();
// foreach (quint16 adr,m_memusagemap.addressesWhichContain(OperationArg))
// {
// hexdump.append(uint16ToHex(adr));
// }
// qDebug() << "Operations Args:" << hexdump;
if (processRecursively) if (processRecursively)
{ {
// m_jlm.dumpJumps();
m_jumplines = m_jlm.buildJumpLines(); m_jumplines = m_jlm.buildJumpLines();
qDebug() << "Num Channels: " << m_jlm.getNumJumpLineChannels(); qDebug() << "Num Channels: " << m_jlm.getNumJumpLineChannels();
} }

View File

@ -54,7 +54,7 @@ ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
setSyntaxHighlighting(settings.value("ASViewer.syntaxHighlighting",true).toBool(), NoReformat); setSyntaxHighlighting(settings.value("ASViewer.syntaxHighlighting",true).toBool(), NoReformat);
setShowCtrlChars(settings.value("ASViewer.showCtrlChars",true).toBool(), NoReformat); setShowCtrlChars(settings.value("ASViewer.showCtrlChars",true).toBool(), NoReformat);
// setTextFont(fontFromSettings("ASViewer.textFont", textAreaFont), NoReformat); setTextFont(fontFromSettings("ASViewer.textFont", textAreaFont), NoReformat);
setTextFont(textAreaFont, NoReformat); setTextFont(textAreaFont, NoReformat);
} }

View File

@ -265,10 +265,28 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address)
return m_bfm->assemblerSymbols()->getSymbolAtAddress(address); return m_bfm->assemblerSymbols()->getSymbolAtAddress(address);
} }
} }
if (address == 0x20) { return "MON.WINDOW_LEFT"; }
if (address == 0x21) { return "MON.WINDOW_WIDTH"; }
if (address == 0x22) { return "MON.WINDOW_TOP"; }
if (address == 0x23) { return "MON.WINDOW_BOTTOM"; }
if (address == 0x24) { return "MON.CURSORHORIZ"; } if (address == 0x24) { return "MON.CURSORHORIZ"; }
if (address == 0x25) { return "MON.CURSORVERT"; }
if (address == 0x28) { return "MON.BASL"; } if (address == 0x28) { return "MON.BASL"; }
if (address == 0x29) { return "MON.BASH"; } if (address == 0x29) { return "MON.BASH"; }
if (address == 0x2A) { return "DOS.SCRATCH"; }
if (address == 0x2B) { return "DOS.BOOT_SLOT"; }
if (address == 0x2C) { return "DOS.RWTS_CKSUM"; }
if (address == 0x2D) { return "DOS.RWTS_SECTOR"; }
if (address == 0x2E) { return "DOS.RWTS_TRACK"; }
if (address == 0x2F) { return "DOS.RWTS_VOLUME"; }
if (address == 0x30) { return "MON.HIRES_TMPBM"; }
if (address == 0x32) { return "MON.VIDEO_MODE"; }
if (address == 0x33) { return "MON.PROMPTCHAR"; } if (address == 0x33) { return "MON.PROMPTCHAR"; }
if (address == 0x36) { return "DOS.CSWL"; } if (address == 0x36) { return "DOS.CSWL"; }
if (address == 0x37) { return "DOS.CSWH"; } if (address == 0x37) { return "DOS.CSWH"; }
@ -281,6 +299,10 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address)
if (address == 0x44) { return "DOS.NUMERIC_OPERAND_L"; } if (address == 0x44) { return "DOS.NUMERIC_OPERAND_L"; }
if (address == 0x45) { return "DOS.NUMERIC_OPERAND_H"; } if (address == 0x45) { return "DOS.NUMERIC_OPERAND_H"; }
if (address == 0x48) { return "DOS.RWTS_IOB_PTR_L"; }
if (address == 0x49) { return "DOS.RWRS_IOB_PTR_H"; }
if (address == 0x67) { return "AS.PROG_STARTL"; } if (address == 0x67) { return "AS.PROG_STARTL"; }
if (address == 0x68) { return "AS.PROG_STARTH"; } if (address == 0x68) { return "AS.PROG_STARTH"; }
@ -330,18 +352,37 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address)
if (address == 0xB0) { return "AS.PROGEND_H"; } if (address == 0xB0) { return "AS.PROGEND_H"; }
if (address == 0xD6) { return "DOS.AS.LOCK"; } if (address == 0xD6) { return "DOS.AS.LOCK"; }
if (address == 0xD8) { return "DOS.AS.ONERR"; }
if (address == 0xDA) { return "DOS.AS.ONERR_LINE_L"; }
if (address == 0xDB) { return "DOS.AS.ONERR_LINE_H"; }
if (address == 0xE0) { return "AS.HGR_X_L"; } if (address == 0xE0) { return "AS.HGR_X_L"; }
if (address == 0xE1) { return "AS.HGR_X_H"; } if (address == 0xE1) { return "AS.HGR_X_H"; }
if (address == 0xE2) { return "AS.HGR_Y"; } if (address == 0xE2) { return "AS.HGR_Y"; }
if (address == 0xE4) { return "AS.HGR_COLOR"; } if (address == 0xE4) { return "AS.HGR_COLOR"; }
if (address == 0xE5) { return "AS.HGR_MAP_BYTE"; }
if (address == 0xE6) { return "AS.HGR_PLOT_PAGE"; }
if (address == 0xE7) { return "AS.HGR_SCALE"; }
if (address == 0xE8) { return "AS.SHAPETBL_L"; } if (address == 0xE8) { return "AS.SHAPETBL_L"; }
if (address == 0xE9) { return "AS.SHAPETBL_H"; } if (address == 0xE9) { return "AS.SHAPETBL_H"; }
if (address == 0xEA) { return "AS.HGR_COLLISION_CTR"; } if (address == 0xEA) { return "AS.HGR_COLLISION_CTR"; }
if (address == 0xF0) { return "AS.LORES_SCRATCH"; }
if (address == 0xF1) { return "AS.255_MINUS_SPEED"; }
if (address == 0xF2) { return "AS.TRACE_FLAG"; }
if (address == 0xF3) { return "MON.FLASH_MASK"; }
if (address == 0xF4) { return "AS.ONERR_PTR_AREA_0"; }
if (address == 0xF5) { return "AS.ONERR_PTR_AREA_1"; }
if (address == 0xF6) { return "AS.ONERR_PTR_AREA_2"; }
if (address == 0xF7) { return "AS.ONERR_PTR_AREA_3"; }
if (address == 0xF8) { return "AS.ONERR_PTR_AREA_4"; }
if (address == 0xF9) { return "AS.HGR_ROT"; }
if (address == 0x03d0) { return "DOS.WARMSTART"; } if (address == 0x03d0) { return "DOS.WARMSTART"; }
if (address == 0x03d3) { return "DOS.COLDSTART"; } if (address == 0x03d3) { return "DOS.COLDSTART"; }
if (address == 0x03d6) { return "DOS.FILE_MANAGER"; } if (address == 0x03d6) { return "DOS.FILE_MANAGER"; }