Improved disassembler labelling

This commit is contained in:
mlong 2021-01-23 14:23:41 -06:00
parent c8b62f883a
commit f5d4d99a94
3 changed files with 26 additions and 3 deletions

View File

@ -21,6 +21,19 @@ int AssemblerSymbols::locationOfSymbolAtAddress(quint16 address)
return -1; return -1;
} }
QString AssemblerSymbols::getSymbolAtAddress(quint16 address)
{
int loc = locationOfSymbolAtAddress(address);
if (loc < 0)
{
return "";
}
else
{
return m_assemblerSymbols.at(loc).name;
}
}
bool AssemblerSymbols::hasAssemSymbolAtAddress(quint16 address) bool AssemblerSymbols::hasAssemSymbolAtAddress(quint16 address)
{ {
// Assume list m_assemblerSymbols is sorted by address (it should be) // Assume list m_assemblerSymbols is sorted by address (it should be)

View File

@ -5,7 +5,7 @@
#include <QDataStream> #include <QDataStream>
typedef enum { typedef enum {
SizeUnknown = 0, // SizeUnknown = 0,
SizeByte = 1, SizeByte = 1,
SizeWord = 2 SizeWord = 2
} SymbolSize; } SymbolSize;
@ -39,6 +39,7 @@ public:
void doTestData(); void doTestData();
int locationOfSymbolAtAddress(quint16 address); int locationOfSymbolAtAddress(quint16 address);
QString getSymbolAtAddress(quint16 address);
signals: signals:
void symbolAdded(AssemblerSymbol &AssemblerSymbol, int location); void symbolAdded(AssemblerSymbol &AssemblerSymbol, int location);
void symbolAddedAt(int location); void symbolAddedAt(int location);

View File

@ -202,7 +202,7 @@ void DisassemblerViewer::disassemble(QList<quint16> entryPoints) {
newline = QString("%1: .Byte $%2 ; %3").arg(uint16ToHex(idx)) newline = QString("%1: .Byte $%2 ; %3").arg(uint16ToHex(idx))
.arg(uint8ToHex(m_mem.at(idx))) .arg(uint8ToHex(m_mem.at(idx)))
.arg(m_bfm->assemblerSymbols()->at(loc).name);; .arg(m_bfm->assemblerSymbols()->at(loc).name);;
} } else
if (m_bfm->assemblerSymbols()->at(loc).symbolsize == SizeWord) if (m_bfm->assemblerSymbols()->at(loc).symbolsize == SizeWord)
{ {
newline = QString("%1: .Word $%2 ; %3").arg(uint16ToHex(idx)) newline = QString("%1: .Word $%2 ; %3").arg(uint16ToHex(idx))
@ -231,7 +231,8 @@ void DisassemblerViewer::disassemble(QList<quint16> entryPoints) {
formattedLines.append(newline); formattedLines.append(newline);
} }
} }
qSort(formattedLines); //qSort(formattedLines);
formattedLines.sort();
m_disassemblyStrings = formattedLines; m_disassemblyStrings = formattedLines;
} }
@ -240,6 +241,14 @@ void DisassemblerViewer::disassemble(QList<quint16> entryPoints) {
QString DisassemblerViewer::getPotentialLabel(quint16 address) QString DisassemblerViewer::getPotentialLabel(quint16 address)
{ {
if (m_bfm)
{
if (m_bfm->assemblerSymbols()->hasAssemSymbolAtAddress(address))
{
return m_bfm->assemblerSymbols()->getSymbolAtAddress(address);
}
}
if (address == 0x24) { return "MON.CURSORHORIZ"; } if (address == 0x24) { return "MON.CURSORHORIZ"; }
if (address == 0x28) { return "MON.BASL"; } if (address == 0x28) { return "MON.BASL"; }
if (address == 0x29) { return "MON.BASH"; } if (address == 0x29) { return "MON.BASH"; }