fixed bank crossing branches

This commit is contained in:
thrust26 2021-01-24 10:03:10 +01:00
parent bcc8fe6e6e
commit 06a70ec90b
2 changed files with 23 additions and 9 deletions

View File

@ -86,7 +86,8 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
if (myDbg.addressType(k + myOffset) == CartDebug::AddrType::ROM) { if (myDbg.addressType(k + myOffset) == CartDebug::AddrType::ROM) {
reservedLabel.str(""); reservedLabel.str("");
labelHigh(reservedLabel, k + myOffset); labelHigh(reservedLabel, k + myOffset);
myReserved.Label.emplace(k + myOffset, reservedLabel.str()); myReserved.Label.emplace(CartDebug::BankAddress(myBank, k + myOffset),
reservedLabel.str());
} }
} }
} }
@ -538,15 +539,28 @@ void DiStella::disasm(uInt32 distart, int pass)
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; ad = ((myPC + Int8(d1)) & 0xfff) + myOffset;
labelFound = mark(ad, Device::REFERENCED); // Detect cross-bank branches
bool crossBank = Int32(myPC) + Int8(d1) < myAppData.start
|| Int32(myPC) + Int8(d1) > myAppData.end;
if(!crossBank)
labelFound = mark(ad, Device::REFERENCED);
else
{
labelFound = AddressType::INVALID;
cerr << myBank << "_" << myPC << ": " << Base::HEX2 << std::to_string(Int8(d1)) << endl;
}
if(pass == 3) { if(pass == 3) {
if(labelFound == AddressType::ROM) { if(labelFound == AddressType::ROM) {
nextLine << " "; nextLine << " ";
LABEL_HIGH(ad); LABEL_HIGH(ad);
} }
else else if(!crossBank)
nextLine << " $" << Base::HEX4 << ad; nextLine << " $" << Base::HEX4 << ad;
else
nextLine << " . " << (Int8(d1) > 0 ? "+" : "-")
<< " $" << Base::HEX2 << std::to_string(abs(Int8(d1)));
nextLineBytes << Base::HEX2 << int(d1); nextLineBytes << Base::HEX2 << int(d1);
} }
break; break;

View File

@ -117,13 +117,13 @@ class DiStella
// Convenience methods to generate appropriate labels // Convenience methods to generate appropriate labels
inline void lineLabelHigh(stringstream& buf, uInt16 addr) inline void lineLabelHigh(stringstream& buf, uInt16 addr)
{ {
stringstream buf8; stringstream buf10; // must be formatted as '8x'
buf8 << "'L"; buf10 << "'L";
if(myNumBanks > 1) if(myNumBanks > 1)
buf8 << Common::Base::HEX1 << myBank << "_"; buf10 << Common::Base::HEX1 << myBank << "_";
buf8 << Common::Base::HEX4 << addr; buf10 << Common::Base::HEX4 << addr;
buf << std::left << std::setw(9) << std::setfill(' ') << buf8.str() << "'"; buf << std::left << std::setw(9) << std::setfill(' ') << buf10.str() << "'";
} }
inline void labelHigh(stringstream& buf, uInt16 addr) inline void labelHigh(stringstream& buf, uInt16 addr)