mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-11 17:29:57 +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);
|
Disassembly(mc6809& processor);
|
||||||
|
|
||||||
std::string disassemble(uint16_t current);
|
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_Flags(uint8_t value);
|
||||||
static std::string dump_ByteValue(uint8_t value);
|
static std::string dump_ByteValue(uint8_t value);
|
||||||
static std::string dump_RelativeValue(int8_t value);
|
static std::string dump_RelativeValue(int8_t value);
|
||||||
static std::string dump_WordValue(uint16_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(int16_t value);
|
||||||
|
static std::string dump_RelativeValue(register16_t value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mc6809& m_cpu;
|
mc6809& m_cpu;
|
||||||
|
@ -40,18 +40,55 @@ std::string EightBit::Disassembly::dump_RelativeValue(int8_t value) {
|
|||||||
return output.str();
|
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::string EightBit::Disassembly::dump_WordValue(uint16_t value) {
|
||||||
std::ostringstream output;
|
std::ostringstream output;
|
||||||
dump(output, value, 4);
|
dump(output, value, 4);
|
||||||
return output.str();
|
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::string EightBit::Disassembly::dump_RelativeValue(int16_t value) {
|
||||||
std::ostringstream output;
|
std::ostringstream output;
|
||||||
output << (int)value;
|
output << (int)value;
|
||||||
return output.str();
|
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) {
|
std::string EightBit::Disassembly::disassemble(uint16_t current) {
|
||||||
|
|
||||||
m_address = current;
|
m_address = current;
|
||||||
|
@ -27,26 +27,13 @@ void Board::initialise() {
|
|||||||
CPU().reset();
|
CPU().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::Cpu_ExecutingInstruction_Debug(EightBit::mc6809& cpu) {
|
void Board::Cpu_ExecutingInstruction_Debug(EightBit::mc6809&) {
|
||||||
|
const auto disassembled = m_disassembler.disassemble();
|
||||||
auto address = cpu.PC().word;
|
if (!disassembled.empty())
|
||||||
auto cell = peek(address);
|
std::cout
|
||||||
|
<< m_disassembler.dumpState()
|
||||||
const auto disassembled = m_disassembler.disassemble(address);
|
<< disassembled
|
||||||
if (!disassembled.empty()) {
|
<< std::endl;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t& Board::reference(uint16_t address) {
|
uint8_t& Board::reference(uint16_t address) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user