From e0ee03184517737bb5a01f98142ad713324bda7c Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sat, 22 Oct 2022 23:31:04 -0700 Subject: Initial interrupt controller support --- isa/decode.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'isa/decode.cpp') diff --git a/isa/decode.cpp b/isa/decode.cpp index 1ecb189..d709cf8 100644 --- a/isa/decode.cpp +++ b/isa/decode.cpp @@ -73,6 +73,72 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit break; case 6: // IOT switch ((bits >> 3) & 077) { + case 000: + // INTERRUPT CONTROLLER + switch (bits & 07) { + case 0: + // SKON skip if interrupts enabled + inst.read_ctlreg = INT_ENABLE; + inst.possibly_redirects = true; + inst.ef = [](auto &ctx) { + if (ctx.ctlval.value() & 1) + ctx.next_pc = (ctx.next_pc & 07777) | ((ctx.next_pc + 1) & 07777); + }; + break; + case 1: + // ION set int_enable_delay + inst.read_ctlreg = INT_ENABLE; + inst.write_ctlreg = INT_ENABLE; + inst.ef = [](auto &ctx) { + ctx.ctlval.value() |= 2; + }; + break; + case 2: + // IOFF clear int_enable and int_enable_delay + inst.write_ctlreg = INT_ENABLE; + inst.ef = [](auto &ctx) { + ctx.ctlval = 0; + }; + break; + case 3: + // SRQ skip if pending interrupt + inst.read_ctlreg = INT_PENDING; + inst.possibly_redirects = true; + inst.ef = [](auto &ctx) { + if (ctx.ctlval.value()) + ctx.next_pc = (ctx.next_pc & 07777) | ((ctx.next_pc + 1) & 07777); + }; + break; + case 4: + // GTF get flags + inst.ef = [](auto &ctx) { + assert(false); + }; + break; + case 5: + // RTF restore flags + inst.ef = [](auto &ctx) { + assert(false); + }; + break; + case 6: + // SGT skip if greater than + inst.ef = [](auto &ctx) { + assert(false); + }; + break; + case 7: + // CAF clear all flags + inst.ef = [](auto &ctx) { + assert(false); + }; + break; + default: + inst.ef = [](auto &ctx) { + assert(false); + }; + } + break; case 004: // TELETYPE TELEPRINTER/PUNCH switch (bits & 07) { -- cgit v1.2.3