blob: 05b59a921864b4854fa994bbb89c97a441bbe55b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <cassert>
#include "isa/checker.h"
#include "isa/isa.h"
void checker::execute() {
assert(!halted);
auto int_enable_delay = ctlregs[INT_ENABLE] >> 1;
if (ctlregs[INT_ENABLE] & 1) {
// check for interrupt
}
ctlregs[INT_ENABLE] = (int_enable_delay << 1) | int_enable_delay;
inst = decode(ctlregs[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;
halted = inst.halt;
}
|