diff options
| author | Julian Blake Kongslie | 2022-10-02 15:32:49 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-10-02 15:32:49 -0700 |
| commit | 82cc71261d3d32012d33d3bebe56ca5e3b0bcdbd (patch) | |
| tree | f1358a38d244e27d9740e914c54328d753cb0b4f /isa/checker.cpp | |
| download | biggolf-82cc71261d3d32012d33d3bebe56ca5e3b0bcdbd.tar.xz | |
Initial commit.
Diffstat (limited to '')
| -rw-r--r-- | isa/checker.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
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 @@ | |||
| 1 | #include <cassert> | ||
| 2 | |||
| 3 | #include "isa/isa.h" | ||
| 4 | |||
| 5 | void checker::execute() { | ||
| 6 | assert(!halt); | ||
| 7 | auto int_enable_delay = ctlregs[ctlreg::INT_ENABLE] >> 1; | ||
| 8 | if (ctlregs[ctlreg::INT_ENABLE] & 1) { | ||
| 9 | // check for interrupt | ||
| 10 | } | ||
| 11 | ctlregs[ctlreg::INT_ENABLE] = (int_enable_delay << 1) | int_enable_delay; | ||
| 12 | inst = decode(ctlregs[ctlreg::DATA_INSTRUCTION_FIELD_BUFFER], | ||
| 13 | pc, | ||
| 14 | mem.fetch(pc)); | ||
| 15 | auto next_pc = inst.next_pc; | ||
| 16 | if (inst.need_indirect_load) { | ||
| 17 | auto addr = mem.fetch(inst.init_address.value()); | ||
| 18 | if (inst.need_autoinc_store) | ||
| 19 | mem.store(*inst.init_address, (addr + 1) & 07777); | ||
| 20 | inst.final_address = addr; | ||
| 21 | } else { | ||
| 22 | assert(!inst.need_autoinc_store); | ||
| 23 | } | ||
| 24 | if (inst.need_exec_load) | ||
| 25 | inst.data = mem.fetch(inst.final_address.value()); | ||
| 26 | if (inst.need_read_acc) | ||
| 27 | inst.acc = acc; | ||
| 28 | if (inst.need_read_link) | ||
| 29 | inst.link = link; | ||
| 30 | if (inst.read_ctlreg.has_value()) | ||
| 31 | inst.ctlval = ctlregs[*inst.read_ctlreg]; | ||
| 32 | inst.execute(); | ||
| 33 | if (inst.need_write_acc) | ||
| 34 | acc = inst.acc.value(); | ||
| 35 | if (inst.need_write_link) | ||
| 36 | link = inst.link.value(); | ||
| 37 | if (inst.write_ctlreg.has_value()) | ||
| 38 | ctlregs[*inst.write_ctlreg] = inst.ctlval.value(); | ||
| 39 | if (inst.need_exec_store) | ||
| 40 | mem.store(inst.final_address.value(), inst.data.value()); | ||
| 41 | assert(inst.next_pc == next_pc || inst.possibly_redirects); | ||
| 42 | pc = inst.next_pc; | ||
| 43 | halt = inst.halt; | ||
| 44 | } | ||
