From ff66523bb076a246c2fc159f0f76947bd6f84fc1 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sat, 29 Oct 2022 12:55:08 -0700 Subject: Control register values should not be "unsigned int" --- isa/checker.h | 3 ++- isa/decode.cpp | 19 +++++++++++++++++++ isa/isa.h | 3 ++- 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'isa') diff --git a/isa/checker.h b/isa/checker.h index 332c483..571bbc8 100644 --- a/isa/checker.h +++ b/isa/checker.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "io/model.h" @@ -41,7 +42,7 @@ struct checker { unsigned int link = 0; unsigned int mq = 0; unsigned int pc = 00200; - std::array ctlregs; + std::array ctlregs; iomodel &system; instruction_context inst; funcmem mem; diff --git a/isa/decode.cpp b/isa/decode.cpp index 4af9a0d..9563327 100644 --- a/isa/decode.cpp +++ b/isa/decode.cpp @@ -140,6 +140,25 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit break; } break; + case 003: + // KEYBOARD + switch (bits & 07) { + case 1: + // KSF skip if TTI flag is set + inst.read_ctlreg = TT_BITS; + inst.possibly_redirects = true; + inst.ef = [](auto &ctx) { + if (ctx.ctlval.value() & TTI_FLAG) + ctx.next_pc = (ctx.next_pc & ~07777) | ((ctx.next_pc + 1) & 07777); + }; + break; + default: + inst.ef = [bits](auto &ctx) { + std::cerr << "unimplemented IOT KB suboperation " << (bits & 07) << "\n"; + assert(false); + }; + } + break; case 004: // TELETYPE TELEPRINTER/PUNCH switch (bits & 07) { diff --git a/isa/isa.h b/isa/isa.h index 1ad5a77..84a783c 100644 --- a/isa/isa.h +++ b/isa/isa.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -49,7 +50,7 @@ struct instruction_context { unsigned int next_pc; // includes IF std::optional init_address; // includes DF std::optional final_address; // includes DF - std::optional ctlval; + std::optional ctlval; // control registers may be larger than 16 bits (e.g. TT_BITS) std::optional data; std::optional acc; std::optional link; -- cgit v1.2.3