mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-11-22 00:31:04 +00:00
Added rudimentary label searching
This commit is contained in:
parent
b7eedfb688
commit
bac8be4688
@ -81,7 +81,7 @@ DisassembledItem Disassembler::disassembleOp(quint16 address, quint16 *nextAddre
|
||||
break;
|
||||
}
|
||||
case AM_Immediate:{
|
||||
disassemblyLine = QString("%1 #_ARG8_").arg(op.mnemonic());
|
||||
disassemblyLine = QString("%1 #%2").arg(op.mnemonic()).arg((quint8) hexValues[1],2,16,QChar('0')).toUpper();
|
||||
retval.setRawArgument(hexValues[1]);
|
||||
break;
|
||||
}
|
||||
@ -102,7 +102,7 @@ DisassembledItem Disassembler::disassembleOp(quint16 address, quint16 *nextAddre
|
||||
disassemblyLine = QString("%1 _ARG16_ {%2%3}").arg(op.mnemonic())
|
||||
.arg((offset<0)?"-":"+")
|
||||
.arg(abs(offset));
|
||||
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
|
||||
retval.setRawArgument(offsetAddress);
|
||||
break;
|
||||
}
|
||||
case AM_ZeroPage:{
|
||||
|
@ -109,16 +109,18 @@ public:
|
||||
void setJump(bool jump) { m_is_jump = jump; }
|
||||
void setJsr(bool jsr) { m_is_jsr = jsr; }
|
||||
void setTargetAddress(quint16 ta) { m_unknown_ta = false; m_target_address = ta; }
|
||||
void setRawArgument(quint16 arg) { m_raw_arg = arg; }
|
||||
void setRawArgument(quint16 arg) { m_has_arg = true; m_raw_arg = arg; }
|
||||
|
||||
AssyInstruction assyInstruction() const { return m_instruction; }
|
||||
QString rawDisassembledString() const { return m_disassembly_text; }
|
||||
QString disassembledString() {
|
||||
QString retval = rawDisassembledString();
|
||||
if (retval.contains("_ARG16_")) {
|
||||
retval.replace("_ARG16_","$"+arg16Str());
|
||||
} else if (retval.contains("_ARG8_")) {
|
||||
retval.replace("_ARG8_","$"+arg8Str());
|
||||
if (hasArg()) {
|
||||
if (retval.contains("_ARG16_")) {
|
||||
retval.replace("_ARG16_","$"+arg16Str());
|
||||
} else if (retval.contains("_ARG8_")) {
|
||||
retval.replace("_ARG8_","$"+arg8Str());
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -130,7 +132,7 @@ public:
|
||||
bool isJump() const { return m_is_jump; }
|
||||
bool isJsr() const { return m_is_jsr; }
|
||||
quint16 targetAddress() const { return m_target_address; }
|
||||
|
||||
bool hasArg() const { return m_has_arg; }
|
||||
quint16 arg16() { return m_raw_arg; }
|
||||
quint8 arg8() { return m_raw_arg % 256; }
|
||||
QString arg16Str() { return QString("%1").arg(arg16(),4,16,QChar('0')).toUpper(); }
|
||||
@ -142,6 +144,7 @@ private:
|
||||
m_is_jump = m_is_branch = m_is_jsr = false;
|
||||
m_unknown_ta = true;
|
||||
m_raw_arg = 0;
|
||||
m_has_arg = false;
|
||||
}
|
||||
|
||||
quint16 m_address;
|
||||
@ -155,6 +158,7 @@ private:
|
||||
AssyInstruction m_instruction;
|
||||
bool m_unknown_ta;
|
||||
quint16 m_raw_arg;
|
||||
bool m_has_arg;
|
||||
};
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "disassembler.h"
|
||||
#include "memory.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
DisassemblerViewer::DisassemblerViewer(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::DisassemblerViewer)
|
||||
@ -34,7 +36,17 @@ void DisassemblerViewer::setFile(BinaryFile *file) {
|
||||
QStringList formattedLines;
|
||||
|
||||
foreach (DisassembledItem di, lines) {
|
||||
QString newline = QString("%1: %2 %3").arg(di.hexAddress()).arg(di.hexString()).arg(di.disassembledString());
|
||||
QString ds = di.rawDisassembledString();
|
||||
if (di.hasArg()) {
|
||||
QString potentialLabel = getPotentialLabel(di.arg16());
|
||||
if (!potentialLabel.isEmpty()) {
|
||||
if (ds.contains("_ARG16_")) { ds.replace("_ARG16_",potentialLabel); }
|
||||
else if (ds.contains("_ARG8_")) { ds.replace("_ARG8_",potentialLabel); }
|
||||
} else {
|
||||
ds = di.disassembledString();
|
||||
}
|
||||
}
|
||||
QString newline = QString("%1: %2 %3").arg(di.hexAddress()).arg(di.hexString()).arg(ds);
|
||||
formattedLines.append(newline);
|
||||
}
|
||||
|
||||
@ -42,6 +54,14 @@ void DisassemblerViewer::setFile(BinaryFile *file) {
|
||||
setData(joinedlines);
|
||||
}
|
||||
|
||||
QString DisassemblerViewer::getPotentialLabel(quint16 address) {
|
||||
QString retval = QString();
|
||||
|
||||
if (address == 0x7129) { retval = "TESTLABEL"; }
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void DisassemblerViewer::setData(QByteArray data)
|
||||
{
|
||||
ui->textArea->setText(data);
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
void setData(QByteArray data);
|
||||
void setText(QString text);
|
||||
|
||||
QString getPotentialLabel(quint16 address);
|
||||
private:
|
||||
Ui::DisassemblerViewer *ui;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user