Align variable-length instructions in disassembly view
MODIFY
src/assembler/objdump.cpp
src/assembler/objdump.cpp
@@ -28,8 +28,10 @@ QString stringifyProgram(std::weak_ptr<const Program> program, Stringifier strin
auto dataStream = QDataStream(textSection->data);
std::vector<char> buffer;
const unsigned regBytes = ProcessorHandler::currentISA()->bytes();
+ const unsigned instrBytes = ProcessorHandler::currentISA()->instrBytes();
int infoOffsets = 0;
+ const QString indent = " ";
AInt addr = textSection->address;
while (addr < textSection->address + textSection->data.length()) {
@@ -54,7 +56,7 @@ QString stringifyProgram(std::weak_ptr<const Program> program, Stringifier strin
}
// Instruction address
- out += "\t" + QString::number(addr, 16) + ":\t\t";
+ out += indent + QString::number(addr, 16) + ":" + indent + indent;
// Stringified instruction
auto disres = stringifier(buffer, addr);
@@ -66,7 +68,17 @@ QString stringifyProgram(std::weak_ptr<const Program> program, Stringifier strin
wordString.prepend(QString().setNum(static_cast<uint8_t>(*it), 16).rightJustified(2, '0'));
buffer.erase(it);
}
- out += wordString + "\t\t";
+
+ out += wordString + indent + indent;
+
+ // Pad if < default instruction width to align disassembled instruction with default instruction width
+ // column
+ int dBytes = instrBytes - disres.bytesDisassembled;
+ while (dBytes > 0) {
+ out += indent;
+ dBytes -= indent.size() / 2;
+ }
+
out += disres.repr + "\n";
addr += disres.bytesDisassembled;
}

Align variable-length instructions in disassembly view #132