mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-24 06:29:42 +00:00
Simplify the 6809 disassembler usage a little.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
974d5fbd14
commit
a5e51f7140
@ -11,12 +11,18 @@ namespace EightBit {
|
||||
Disassembly(mc6809& processor);
|
||||
|
||||
std::string disassemble(uint16_t current);
|
||||
std::string disassemble(register16_t current);
|
||||
std::string disassemble();
|
||||
|
||||
std::string dumpState();
|
||||
|
||||
static std::string dump_Flags(uint8_t value);
|
||||
static std::string dump_ByteValue(uint8_t value);
|
||||
static std::string dump_RelativeValue(int8_t value);
|
||||
static std::string dump_WordValue(uint16_t value);
|
||||
static std::string dump_WordValue(register16_t value);
|
||||
static std::string dump_RelativeValue(int16_t value);
|
||||
static std::string dump_RelativeValue(register16_t value);
|
||||
|
||||
private:
|
||||
mc6809& m_cpu;
|
||||
|
@ -40,18 +40,55 @@ std::string EightBit::Disassembly::dump_RelativeValue(int8_t value) {
|
||||
return output.str();
|
||||
}
|
||||
|
||||
std::string EightBit::Disassembly::dump_WordValue(register16_t value) {
|
||||
return dump_WordValue(value.word);
|
||||
}
|
||||
|
||||
std::string EightBit::Disassembly::dump_WordValue(uint16_t value) {
|
||||
std::ostringstream output;
|
||||
dump(output, value, 4);
|
||||
return output.str();
|
||||
}
|
||||
|
||||
std::string EightBit::Disassembly::dump_RelativeValue(register16_t value) {
|
||||
return dump_RelativeValue((int16_t)value.word);
|
||||
}
|
||||
|
||||
std::string EightBit::Disassembly::dump_RelativeValue(int16_t value) {
|
||||
std::ostringstream output;
|
||||
output << (int)value;
|
||||
return output.str();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
std::string EightBit::Disassembly::dumpState() {
|
||||
|
||||
std::ostringstream output;
|
||||
|
||||
output << std::hex;
|
||||
output << "PC=" << dump_WordValue(CPU().PC()) << ":";
|
||||
output << "CC=" << dump_Flags(CPU().CC()) << ",";
|
||||
output << "D=" << dump_WordValue(CPU().D()) << ",";
|
||||
output << "X=" << dump_WordValue(CPU().X()) << ",";
|
||||
output << "Y=" << dump_WordValue(CPU().Y()) << ",";
|
||||
output << "U=" << dump_WordValue(CPU().U()) << ",";
|
||||
output << "S=" << dump_WordValue(CPU().S()) << ",";
|
||||
output << "DP=" << dump_ByteValue(CPU().DP()) << "\t";
|
||||
|
||||
return output.str();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
std::string EightBit::Disassembly::disassemble() {
|
||||
return disassemble(CPU().PC());
|
||||
}
|
||||
|
||||
std::string EightBit::Disassembly::disassemble(register16_t current) {
|
||||
return disassemble(current.word);
|
||||
}
|
||||
|
||||
std::string EightBit::Disassembly::disassemble(uint16_t current) {
|
||||
|
||||
m_address = current;
|
||||
|
@ -27,26 +27,13 @@ void Board::initialise() {
|
||||
CPU().reset();
|
||||
}
|
||||
|
||||
void Board::Cpu_ExecutingInstruction_Debug(EightBit::mc6809& cpu) {
|
||||
|
||||
auto address = cpu.PC().word;
|
||||
auto cell = peek(address);
|
||||
|
||||
const auto disassembled = m_disassembler.disassemble(address);
|
||||
if (!disassembled.empty()) {
|
||||
|
||||
std::cout << std::hex;
|
||||
std::cout << "PC=" << EightBit::Disassembly::dump_WordValue(address) << ":";
|
||||
std::cout << "CC=" << EightBit::Disassembly::dump_Flags(CPU().CC()) << ",";
|
||||
std::cout << "D=" << EightBit::Disassembly::dump_WordValue(CPU().D().word) << ",";
|
||||
std::cout << "X=" << EightBit::Disassembly::dump_WordValue(CPU().X().word) << ",";
|
||||
std::cout << "Y=" << EightBit::Disassembly::dump_WordValue(CPU().Y().word) << ",";
|
||||
std::cout << "U=" << EightBit::Disassembly::dump_WordValue(CPU().U().word) << ",";
|
||||
std::cout << "S=" << EightBit::Disassembly::dump_WordValue(CPU().S().word) << ",";
|
||||
std::cout << "DP=" << EightBit::Disassembly::dump_ByteValue(CPU().DP()) << "\t";
|
||||
|
||||
std::cout << disassembled << std::endl;
|
||||
}
|
||||
void Board::Cpu_ExecutingInstruction_Debug(EightBit::mc6809&) {
|
||||
const auto disassembled = m_disassembler.disassemble();
|
||||
if (!disassembled.empty())
|
||||
std::cout
|
||||
<< m_disassembler.dumpState()
|
||||
<< disassembled
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
uint8_t& Board::reference(uint16_t address) {
|
||||
|
Loading…
Reference in New Issue
Block a user