mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2025-01-02 07:29:20 +00:00
Changed disassembler to templatize arguments in prep for using labels, potentially.
This commit is contained in:
parent
f3128e073a
commit
b7eedfb688
@ -56,38 +56,33 @@ DisassembledItem Disassembler::disassembleOp(quint16 address, quint16 *nextAddre
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_Absolute:{
|
case AM_Absolute:{
|
||||||
disassemblyLine = QString("%1 $%2%3").arg(op.mnemonic())
|
disassemblyLine = QString("%1 _ARG16_").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[2],2,16,QChar('0'))
|
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_AbsoluteIndexedIndirect:{
|
case AM_AbsoluteIndexedIndirect:{
|
||||||
disassemblyLine = QString("%1 ($%2%3,x)").arg(op.mnemonic())
|
disassemblyLine = QString("%1 (_ARG16_,x)").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[2],2,16,QChar('0'))
|
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_AbsoluteIndexedWithX:{
|
case AM_AbsoluteIndexedWithX:{
|
||||||
disassemblyLine = QString("%1 $%2%3,x").arg(op.mnemonic())
|
disassemblyLine = QString("%1 _ARG16_,x").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[2],2,16,QChar('0'))
|
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_AbsoluteIndexedWithY:{
|
case AM_AbsoluteIndexedWithY:{
|
||||||
disassemblyLine = QString("%1 $%2%3,y").arg(op.mnemonic())
|
disassemblyLine = QString("%1 _ARG16_,y").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[2],2,16,QChar('0'))
|
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_AbsoluteIndirect:{
|
case AM_AbsoluteIndirect:{
|
||||||
disassemblyLine = QString("%1 ($%2%3)").arg(op.mnemonic())
|
disassemblyLine = QString("%1 (_ARG16_)").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[2],2,16,QChar('0'))
|
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_Immediate:{
|
case AM_Immediate:{
|
||||||
disassemblyLine = QString("%1 #$%2").arg(op.mnemonic())
|
disassemblyLine = QString("%1 #_ARG8_").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
retval.setRawArgument(hexValues[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_Implied:{
|
case AM_Implied:{
|
||||||
@ -104,40 +99,40 @@ DisassembledItem Disassembler::disassembleOp(quint16 address, quint16 *nextAddre
|
|||||||
|
|
||||||
retval.setTargetAddress(offsetAddress);
|
retval.setTargetAddress(offsetAddress);
|
||||||
|
|
||||||
disassemblyLine = QString("%1 $%2 {%3%4}").arg(op.mnemonic())
|
disassemblyLine = QString("%1 _ARG16_ {%2%3}").arg(op.mnemonic())
|
||||||
.arg((quint16) offsetAddress,4,16,QChar('0'))
|
|
||||||
.arg((offset<0)?"-":"+")
|
.arg((offset<0)?"-":"+")
|
||||||
.arg(abs(offset));
|
.arg(abs(offset));
|
||||||
|
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_ZeroPage:{
|
case AM_ZeroPage:{
|
||||||
disassemblyLine = QString("%1 $%2").arg(op.mnemonic())
|
disassemblyLine = QString("%1 _ARG8_").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
retval.setRawArgument(hexValues[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_ZeroPageIndirectIndexedWithY:{
|
case AM_ZeroPageIndirectIndexedWithY:{
|
||||||
disassemblyLine = QString("%1 ($%2),y").arg(op.mnemonic())
|
disassemblyLine = QString("%1 (_ARG8_),Y").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
retval.setRawArgument(hexValues[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_ZeroPageIndexedIndirect:{
|
case AM_ZeroPageIndexedIndirect:{
|
||||||
disassemblyLine = QString("%1 ($%2,x)").arg(op.mnemonic())
|
disassemblyLine = QString("%1 (_ARG8_,x)").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
retval.setRawArgument(hexValues[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_ZeroPageIndexedWithX:{
|
case AM_ZeroPageIndexedWithX:{
|
||||||
disassemblyLine = QString("%1 $%2,x").arg(op.mnemonic())
|
disassemblyLine = QString("%1 _ARG8_,x").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
retval.setRawArgument(hexValues[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_ZeroPageIndexedWithY:{
|
case AM_ZeroPageIndexedWithY:{
|
||||||
disassemblyLine = QString("%1 $%2,y").arg(op.mnemonic())
|
disassemblyLine = QString("%1 _ARG8_,y").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
retval.setRawArgument(hexValues[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AM_ZeroPageIndirect:{
|
case AM_ZeroPageIndirect:{
|
||||||
disassemblyLine = QString("%1 ($%2)").arg(op.mnemonic())
|
disassemblyLine = QString("%1 (_ARG8_)").arg(op.mnemonic());
|
||||||
.arg((quint8) hexValues[1],2,16,QChar('0'));
|
retval.setRawArgument(hexValues[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:{
|
default:{
|
||||||
|
@ -28,6 +28,7 @@ enum AddressMode {
|
|||||||
struct AssyInstruction {
|
struct AssyInstruction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AssyInstruction(quint8 opcode = 0x00, QString mnemonic = "???", AddressMode am = AM_InvalidOp) {
|
AssyInstruction(quint8 opcode = 0x00, QString mnemonic = "???", AddressMode am = AM_InvalidOp) {
|
||||||
m_opcode = opcode;
|
m_opcode = opcode;
|
||||||
m_mnemonic = mnemonic;
|
m_mnemonic = mnemonic;
|
||||||
@ -40,6 +41,8 @@ public:
|
|||||||
|
|
||||||
quint8 opcode() { return m_opcode; }
|
quint8 opcode() { return m_opcode; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
quint8 numArgs() {
|
quint8 numArgs() {
|
||||||
switch (m_addressMode) {
|
switch (m_addressMode) {
|
||||||
case AM_Absolute:
|
case AM_Absolute:
|
||||||
@ -106,9 +109,19 @@ public:
|
|||||||
void setJump(bool jump) { m_is_jump = jump; }
|
void setJump(bool jump) { m_is_jump = jump; }
|
||||||
void setJsr(bool jsr) { m_is_jsr = jsr; }
|
void setJsr(bool jsr) { m_is_jsr = jsr; }
|
||||||
void setTargetAddress(quint16 ta) { m_unknown_ta = false; m_target_address = ta; }
|
void setTargetAddress(quint16 ta) { m_unknown_ta = false; m_target_address = ta; }
|
||||||
|
void setRawArgument(quint16 arg) { m_raw_arg = arg; }
|
||||||
|
|
||||||
AssyInstruction assyInstruction() const { return m_instruction; }
|
AssyInstruction assyInstruction() const { return m_instruction; }
|
||||||
QString disassembledString() const { return m_disassembly_text; }
|
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());
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
quint16 address() const { return m_address; }
|
quint16 address() const { return m_address; }
|
||||||
QString hexAddress() const { return QString("%1").arg(m_address,4,16,QChar('0')).toUpper(); }
|
QString hexAddress() const { return QString("%1").arg(m_address,4,16,QChar('0')).toUpper(); }
|
||||||
QByteArray hexValues() const { return m_hexvalues; }
|
QByteArray hexValues() const { return m_hexvalues; }
|
||||||
@ -118,11 +131,17 @@ public:
|
|||||||
bool isJsr() const { return m_is_jsr; }
|
bool isJsr() const { return m_is_jsr; }
|
||||||
quint16 targetAddress() const { return m_target_address; }
|
quint16 targetAddress() const { return m_target_address; }
|
||||||
|
|
||||||
|
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(); }
|
||||||
|
QString arg8Str() { return QString("%1").arg(arg8(),2,16,QChar('0')).toUpper(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init() {
|
void init() {
|
||||||
m_address = m_target_address = 0;
|
m_address = m_target_address = 0;
|
||||||
m_is_jump = m_is_branch = m_is_jsr = false;
|
m_is_jump = m_is_branch = m_is_jsr = false;
|
||||||
m_unknown_ta = true;
|
m_unknown_ta = true;
|
||||||
|
m_raw_arg = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint16 m_address;
|
quint16 m_address;
|
||||||
@ -135,6 +154,7 @@ private:
|
|||||||
quint16 m_target_address;
|
quint16 m_target_address;
|
||||||
AssyInstruction m_instruction;
|
AssyInstruction m_instruction;
|
||||||
bool m_unknown_ta;
|
bool m_unknown_ta;
|
||||||
|
quint16 m_raw_arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user