From 82cc71261d3d32012d33d3bebe56ca5e3b0bcdbd Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 2 Oct 2022 15:32:49 -0700 Subject: Initial commit. --- isa/checker.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 isa/checker.cpp (limited to 'isa/checker.cpp') diff --git a/isa/checker.cpp b/isa/checker.cpp new file mode 100644 index 0000000..cd802a8 --- /dev/null +++ b/isa/checker.cpp @@ -0,0 +1,44 @@ +#include + +#include "isa/isa.h" + +void checker::execute() { + assert(!halt); + auto int_enable_delay = ctlregs[ctlreg::INT_ENABLE] >> 1; + if (ctlregs[ctlreg::INT_ENABLE] & 1) { + // check for interrupt + } + ctlregs[ctlreg::INT_ENABLE] = (int_enable_delay << 1) | int_enable_delay; + inst = decode(ctlregs[ctlreg::DATA_INSTRUCTION_FIELD_BUFFER], + pc, + mem.fetch(pc)); + auto next_pc = inst.next_pc; + if (inst.need_indirect_load) { + auto addr = mem.fetch(inst.init_address.value()); + if (inst.need_autoinc_store) + mem.store(*inst.init_address, (addr + 1) & 07777); + inst.final_address = addr; + } else { + assert(!inst.need_autoinc_store); + } + if (inst.need_exec_load) + inst.data = mem.fetch(inst.final_address.value()); + if (inst.need_read_acc) + inst.acc = acc; + if (inst.need_read_link) + inst.link = link; + if (inst.read_ctlreg.has_value()) + inst.ctlval = ctlregs[*inst.read_ctlreg]; + inst.execute(); + if (inst.need_write_acc) + acc = inst.acc.value(); + if (inst.need_write_link) + link = inst.link.value(); + if (inst.write_ctlreg.has_value()) + ctlregs[*inst.write_ctlreg] = inst.ctlval.value(); + if (inst.need_exec_store) + mem.store(inst.final_address.value(), inst.data.value()); + assert(inst.next_pc == next_pc || inst.possibly_redirects); + pc = inst.next_pc; + halt = inst.halt; +} -- cgit v1.2.3