Fixed math error due to quint8 vs quint16 calculations

This commit is contained in:
Mark Long 2016-02-11 09:33:42 -06:00
parent bac8be4688
commit e3146d1818
2 changed files with 29 additions and 13 deletions

View File

@ -41,6 +41,9 @@ DisassembledItem Disassembler::disassembleOp(quint16 address, quint16 *nextAddre
}
quint16 argval = 0;
if (op.numArgs() == 1) { argval = hexValues[1]; }
else if (op.numArgs() == 2) { argval = (quint8) hexValues[1] + ((quint8) hexValues[2] * 256); }
for (int idx = 0; idx < hexValues.length(); idx++) {
hexValueString.append(QString("%1 ").arg((quint8) hexValues[idx],2,16,QChar('0')));
@ -57,32 +60,32 @@ DisassembledItem Disassembler::disassembleOp(quint16 address, quint16 *nextAddre
}
case AM_Absolute:{
disassemblyLine = QString("%1 _ARG16_").arg(op.mnemonic());
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
retval.setRawArgument(argval);
break;
}
case AM_AbsoluteIndexedIndirect:{
disassemblyLine = QString("%1 (_ARG16_,x)").arg(op.mnemonic());
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
retval.setRawArgument(argval);
break;
}
case AM_AbsoluteIndexedWithX:{
disassemblyLine = QString("%1 _ARG16_,x").arg(op.mnemonic());
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
retval.setRawArgument(argval);
break;
}
case AM_AbsoluteIndexedWithY:{
disassemblyLine = QString("%1 _ARG16_,y").arg(op.mnemonic());
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
retval.setRawArgument(argval);
break;
}
case AM_AbsoluteIndirect:{
disassemblyLine = QString("%1 (_ARG16_)").arg(op.mnemonic());
retval.setRawArgument(hexValues[1] + (hexValues[2]*256));
retval.setRawArgument(argval);
break;
}
case AM_Immediate:{
disassemblyLine = QString("%1 #%2").arg(op.mnemonic()).arg((quint8) hexValues[1],2,16,QChar('0')).toUpper();
retval.setRawArgument(hexValues[1]);
retval.setRawArgument(argval);
break;
}
case AM_Implied:{
@ -107,32 +110,32 @@ DisassembledItem Disassembler::disassembleOp(quint16 address, quint16 *nextAddre
}
case AM_ZeroPage:{
disassemblyLine = QString("%1 _ARG8_").arg(op.mnemonic());
retval.setRawArgument(hexValues[1]);
retval.setRawArgument(argval);
break;
}
case AM_ZeroPageIndirectIndexedWithY:{
disassemblyLine = QString("%1 (_ARG8_),Y").arg(op.mnemonic());
retval.setRawArgument(hexValues[1]);
retval.setRawArgument(argval);
break;
}
case AM_ZeroPageIndexedIndirect:{
disassemblyLine = QString("%1 (_ARG8_,x)").arg(op.mnemonic());
retval.setRawArgument(hexValues[1]);
retval.setRawArgument(argval);
break;
}
case AM_ZeroPageIndexedWithX:{
disassemblyLine = QString("%1 _ARG8_,x").arg(op.mnemonic());
retval.setRawArgument(hexValues[1]);
retval.setRawArgument(argval);
break;
}
case AM_ZeroPageIndexedWithY:{
disassemblyLine = QString("%1 _ARG8_,y").arg(op.mnemonic());
retval.setRawArgument(hexValues[1]);
retval.setRawArgument(argval);
break;
}
case AM_ZeroPageIndirect:{
disassemblyLine = QString("%1 (_ARG8_)").arg(op.mnemonic());
retval.setRawArgument(hexValues[1]);
retval.setRawArgument(argval);
break;
}
default:{

View File

@ -57,7 +57,20 @@ void DisassemblerViewer::setFile(BinaryFile *file) {
QString DisassemblerViewer::getPotentialLabel(quint16 address) {
QString retval = QString();
if (address == 0x7129) { retval = "TESTLABEL"; }
if (address == 0x03d0) { retval = "DOS_WARMSTART"; }
else if (address == 0x03d3) { retval = "DOS_COLDSTART"; }
else if (address == 0x03d6) { retval = "DOS_FILE_MANAGER"; }
else if (address == 0x03d9) { retval = "DOS_RWTS"; }
else if (address == 0x03dc) { retval = "DOS_FM_PARAM_LIST_LOCATE"; }
else if (address == 0x03e3) { retval = "DOS_RWTS_PARAM_LIST_LOCATE"; }
else if (address == 0x03ea) { retval = "DOS_REPLACE_DOS_INTERCEPTS"; }
else if (address == 0x03ef) { retval = "DOS_AUTOSTART_BRK_HANDLER"; }
else if (address == 0x03f2) { retval = "DOS_AUTOSTART_RESET_HANDLER"; }
else if (address == 0x03f4) { retval = "DOS_POWERUP_BYTE"; }
else if (address == 0x03f5) { retval = "DOS_AMPERSAND_HANDLER"; }
else if (address == 0x03f8) { retval = "DOS_CTRL_Y_HANDLER"; }
else if (address == 0x03fb) { retval = "DOS_NMI_HANDLER"; }
else if (address == 0x03fe) { retval = "DOS_IRQ_HANDLER"; }
return retval;
}