From 430ed65253573017d16fdc5f7a0aafc25b83e24d Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Wed, 2 Nov 2022 14:04:08 -0700 Subject: Avoid rereading the FLAGS register; use FLAGS_SAVED for GTF. --- isa/decode.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'isa') diff --git a/isa/decode.cpp b/isa/decode.cpp index 77bbe8b..6ea3bb5 100644 --- a/isa/decode.cpp +++ b/isa/decode.cpp @@ -7,9 +7,9 @@ instruction_context decode(std::uint_fast32_t flags, unsigned int pc, unsigned int bits, bool interrupt) { //bool gt = (flags >> 10) & 1; - //bool ir = (flags >> 9) & 1; + bool ir = (flags >> 9) & 1; //bool ii = (flags >> 8) & 1; - //bool ie = (flags >> 7) & 1; + bool ie = (flags >> 7) & 1; //bool u = (flags >> 6) & 1; bool ifb = (flags >> 3) & 7; bool df = flags & 7; @@ -86,41 +86,37 @@ instruction_context decode(std::uint_fast32_t flags, unsigned int pc, unsigned i switch (bits & 07) { case 0: // SKON skip if interrupts enabled - inst.read_ctlreg = FLAGS; inst.possibly_redirects = true; - inst.ef = [](auto &ctx) { - if (ctx.ctlval.value() & FLAG_INT_ENABLE) + inst.ef = [ie](auto &ctx) { + if (ie) ctx.next_pc = (ctx.next_pc & 07777) | ((ctx.next_pc + 1) & 07777); }; break; case 1: // ION set int_enable_delay - inst.read_ctlreg = FLAGS; inst.write_ctlreg = FLAGS; - inst.ef = [](auto &ctx) { - ctx.ctlval.value() |= FLAG_INT_ENABLE_DELAY; + inst.ef = [flags](auto &ctx) { + ctx.ctlval = flags | FLAG_INT_ENABLE_DELAY; }; break; case 2: // IOF clear int_enable and int_enable_delay - inst.read_ctlreg = FLAGS; inst.write_ctlreg = FLAGS; - inst.ef = [](auto &ctx) { - ctx.ctlval.value() &= ~FLAG_INT_ENABLE_DELAY & ~FLAG_INT_ENABLE; + inst.ef = [flags](auto &ctx) { + ctx.ctlval = flags & ~FLAG_INT_ENABLE_DELAY & ~FLAG_INT_ENABLE; }; break; case 3: // SRQ skip if pending interrupt - inst.read_ctlreg = FLAGS; inst.possibly_redirects = true; - inst.ef = [](auto &ctx) { - if (ctx.ctlval.value() & FLAG_INT_REQUEST) + inst.ef = [ir](auto &ctx) { + if (ir) ctx.next_pc = (ctx.next_pc & 07777) | ((ctx.next_pc + 1) & 07777); }; break; case 4: // GTF get flags - inst.read_ctlreg = FLAGS; + inst.read_ctlreg = FLAGS_SAVED; inst.need_read_link = true; inst.ef = [](auto &ctx) { auto flags = ctx.ctlval.value(); @@ -130,12 +126,11 @@ instruction_context decode(std::uint_fast32_t flags, unsigned int pc, unsigned i break; case 5: // RTF restore flags - inst.read_ctlreg = FLAGS; inst.need_read_acc = true; inst.need_write_link = true; inst.write_ctlreg = FLAGS; - inst.ef = [](auto &ctx) { - if ((ctx.ctlval.value() & FLAG_INT_ENABLE) && (ctx.acc.value() & FLAG_INT_ENABLE)) { + inst.ef = [ie](auto &ctx) { + if (ie && (ctx.acc.value() & FLAG_INT_ENABLE)) { ctx.ctlval = ctx.acc.value() | FLAG_INT_ENABLE_DELAY; } else if (ctx.acc.value() & FLAG_INT_ENABLE) { ctx.ctlval = (ctx.acc.value() | FLAG_INT_ENABLE_DELAY) & ~FLAG_INT_ENABLE; @@ -283,11 +278,9 @@ instruction_context decode(std::uint_fast32_t flags, unsigned int pc, unsigned i switch (bits & 07) { case 01: // CDF change data field - inst.read_ctlreg = FLAGS; inst.write_ctlreg = FLAGS; - inst.ef = [field](auto &ctx) { - ctx.ctlval.value() &= ~FLAG_DF; - ctx.ctlval.value() |= field << FLAG_DF_SHIFT; + inst.ef = [flags, field](auto &ctx) { + ctx.ctlval = (flags & ~FLAG_DF) | (field << FLAG_DF_SHIFT); }; break; default: -- cgit v1.2.3