Don't expose the bus via the CPU any more: if a component needs the bus, it should be prepared to hold a reference to it.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2018-10-20 20:52:41 +01:00
parent 9b0cc4542f
commit 1b2ddd8843
19 changed files with 131 additions and 103 deletions

View File

@ -8,7 +8,8 @@
#include <iomanip>
#include <bitset>
EightBit::Disassembler::Disassembler() noexcept {
EightBit::Disassembler::Disassembler(Bus& bus) noexcept
: m_bus(bus) {
// Disable exceptions where too many format arguments are available
m_formatter.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
}
@ -168,8 +169,7 @@ std::string EightBit::Disassembler::disassemble(Intel8080& cpu) {
void EightBit::Disassembler::disassemble(std::ostringstream& output, Intel8080& cpu, uint16_t pc) {
auto& bus = cpu.BUS();
auto opcode = bus.peek(pc);
auto opcode = BUS().peek(pc);
output << hex(opcode);
@ -180,11 +180,11 @@ void EightBit::Disassembler::disassemble(std::ostringstream& output, Intel8080&
auto p = (y & 0b110) >> 1;
auto q = (y & 1);
auto immediate = bus.peek(pc + 1);
auto immediate = BUS().peek(pc + 1);
auto absolute = cpu.peekWord(pc + 1).word;
auto displacement = (int8_t)immediate;
auto relative = pc + displacement + 2;
auto indexedImmediate = bus.peek(pc + 1);
auto indexedImmediate = BUS().peek(pc + 1);
auto dumpCount = 0;
@ -196,7 +196,7 @@ void EightBit::Disassembler::disassemble(std::ostringstream& output, Intel8080&
x, y, z, p, q);
for (int i = 0; i < dumpCount; ++i)
output << hex(bus.peek(pc + i + 1));
output << hex(BUS().peek(pc + i + 1));
output << '\t';
m_formatter.parse(specification);