summaryrefslogtreecommitdiff
path: root/isa
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-10-29 18:18:26 -0700
committerJulian Blake Kongslie2022-10-29 18:18:26 -0700
commit9f4aa97822adc791f700670ef0fc7636849563b7 (patch)
tree0b9d6c1bb1d7d596501df3b77ab3d7b9f191aa4f /isa
parentControl register values should not be "unsigned int" (diff)
downloadbiggolf-9f4aa97822adc791f700670ef0fc7636849563b7.tar.xz
Understanding interrupt handling within SIMH (see echo_int.pal)
Add list of Bugs Add event log file parser More changes associated with widening the ctlregs (FIXME add a typedef) Add some keyboard instructions
Diffstat (limited to 'isa')
-rw-r--r--isa/checker.h3
-rw-r--r--isa/ctlreg.def8
-rw-r--r--isa/decode.cpp22
-rw-r--r--isa/isa.h37
4 files changed, 54 insertions, 16 deletions
diff --git a/isa/checker.h b/isa/checker.h
index 571bbc8..96460cf 100644
--- a/isa/checker.h
+++ b/isa/checker.h
@@ -52,4 +52,7 @@ struct checker {
52 ctlregs.fill(0); 52 ctlregs.fill(0);
53 } 53 }
54 void execute(); 54 void execute();
55 bool done() {
56 return ctlregs[HALTED] && system.done();
57 }
55}; 58};
diff --git a/isa/ctlreg.def b/isa/ctlreg.def
new file mode 100644
index 0000000..c9eab05
--- /dev/null
+++ b/isa/ctlreg.def
@@ -0,0 +1,8 @@
1REG(DATA_INSTRUCTION_FIELD_BUFFER) // (df << 3) | if_buffer
2REG(DATA_INSTRUCTION_FIELD_SAVED) // (df_saved << 3) | if_saved
3REG(HALTED)
4REG(INT_ENABLE) // (int_enable_delay << 1) | int_enable
5REG(INT_PENDING) // only meaningful if interrupts disabled
6REG(TT_BITS) // see TT[IO]_* consts in isa/isa.h
7REG(TT_INPUT_INT_ENABLE) // (status_enable << 1) | (int_enable)
8REG(TT_OUTPUT_INT_ENABLE)
diff --git a/isa/decode.cpp b/isa/decode.cpp
index 9563327..c35118b 100644
--- a/isa/decode.cpp
+++ b/isa/decode.cpp
@@ -152,6 +152,24 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit
152 ctx.next_pc = (ctx.next_pc & ~07777) | ((ctx.next_pc + 1) & 07777); 152 ctx.next_pc = (ctx.next_pc & ~07777) | ((ctx.next_pc + 1) & 07777);
153 }; 153 };
154 break; 154 break;
155 case 5:
156 // KIE set TT_INPUT_INT_ENABLE to the low bit of the accumulator
157 inst.need_read_acc = true;
158 inst.write_ctlreg = TT_INPUT_INT_ENABLE;
159 inst.ef = [](auto &ctx) {
160 ctx.ctlval = ctx.acc.value() & 3;
161 };
162 break;
163 case 6:
164 // KRB transfer keyboard buffer to accumulator and clear TTI flag
165 inst.read_ctlreg = TT_BITS;
166 inst.need_write_acc = true;
167 inst.write_ctlreg = TT_BITS;
168 inst.ef = [](auto &ctx) {
169 ctx.acc = (ctx.ctlval.value() & TTI_DATA) >> TTI_DATA_SHIFT;
170 ctx.ctlval.value() &= ~TTI_FLAG;
171 };
172 break;
155 default: 173 default:
156 inst.ef = [bits](auto &ctx) { 174 inst.ef = [bits](auto &ctx) {
157 std::cerr << "unimplemented IOT KB suboperation " << (bits & 07) << "\n"; 175 std::cerr << "unimplemented IOT KB suboperation " << (bits & 07) << "\n";
@@ -194,7 +212,7 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit
194 inst.write_ctlreg = TT_BITS; 212 inst.write_ctlreg = TT_BITS;
195 inst.ef = [](auto &ctx) { 213 inst.ef = [](auto &ctx) {
196 auto &x = ctx.ctlval.value(); 214 auto &x = ctx.ctlval.value();
197 auto chr = ctx.acc.value() ^ 0x80; 215 auto chr = ctx.acc.value();
198 x &= ~TTO_DATA; 216 x &= ~TTO_DATA;
199 x |= (chr << TTO_DATA_SHIFT) & TTO_DATA; 217 x |= (chr << TTO_DATA_SHIFT) & TTO_DATA;
200 x |= TTO_TX; 218 x |= TTO_TX;
@@ -216,7 +234,7 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit
216 inst.write_ctlreg = TT_BITS; 234 inst.write_ctlreg = TT_BITS;
217 inst.ef = [](auto &ctx) { 235 inst.ef = [](auto &ctx) {
218 auto &x = ctx.ctlval.value(); 236 auto &x = ctx.ctlval.value();
219 auto chr = ctx.acc.value() ^ 0x80; 237 auto chr = ctx.acc.value();
220 x &= ~TTO_FLAG & ~TTO_FLAG_OLD & ~TTO_DATA; 238 x &= ~TTO_FLAG & ~TTO_FLAG_OLD & ~TTO_DATA;
221 x |= (chr << TTO_DATA_SHIFT) & TTO_DATA; 239 x |= (chr << TTO_DATA_SHIFT) & TTO_DATA;
222 x |= TTO_TX; 240 x |= TTO_TX;
diff --git a/isa/isa.h b/isa/isa.h
index 84a783c..6484cd8 100644
--- a/isa/isa.h
+++ b/isa/isa.h
@@ -2,30 +2,39 @@
2 2
3#include <cstdint> 3#include <cstdint>
4#include <functional> 4#include <functional>
5#include <map>
5#include <optional> 6#include <optional>
7#include <string>
6 8
7enum ctlreg { 9enum ctlreg {
8 DATA_INSTRUCTION_FIELD_BUFFER, // (df << 3) | if_buffer 10#define REG(N) N,
9 DATA_INSTRUCTION_FIELD_SAVED, // (df_saved << 3) | if_saved 11#include "ctlreg.def"
10 HALTED, 12#undef REG
11 INT_ENABLE, // (int_enable_delay << 1) | int_enable
12 INT_PENDING, // only meaningful if interrupts disabled
13 TT_BITS, // see below TT[IO]_* consts
14 TT_INPUT_INT_ENABLE,
15 TT_OUTPUT_INT_ENABLE,
16 13
17 NUM_CTLREGS, 14 NUM_CTLREGS,
18}; 15};
19 16
17const char * const ctlreg_names[] = {
18#define REG(N) #N,
19#include "ctlreg.def"
20#undef REG
21};
22
23const std::map<std::string, ctlreg> ctlreg_map = {
24#define REG(N) { #N, N },
25#include "ctlreg.def"
26#undef REG
27};
28
20// TT_BITS 29// TT_BITS
21static constexpr unsigned int TTI_FLAG = 1 << 0; 30static constexpr std::uint_fast32_t TTI_FLAG = 1 << 0;
22static constexpr unsigned int TTO_TX = 1 << 1; 31static constexpr std::uint_fast32_t TTO_TX = 1 << 1;
23static constexpr unsigned int TTO_FLAG = 1 << 2; 32static constexpr std::uint_fast32_t TTO_FLAG = 1 << 2;
24static constexpr unsigned int TTO_FLAG_OLD = 1 << 3; 33static constexpr std::uint_fast32_t TTO_FLAG_OLD = 1 << 3;
25static constexpr unsigned int TTI_DATA_SHIFT = 8; 34static constexpr unsigned int TTI_DATA_SHIFT = 8;
26static constexpr unsigned int TTO_DATA_SHIFT = 16; 35static constexpr unsigned int TTO_DATA_SHIFT = 16;
27static constexpr unsigned int TTI_DATA = 0xff << TTI_DATA_SHIFT; 36static constexpr std::uint_fast32_t TTI_DATA = 0xff << TTI_DATA_SHIFT;
28static constexpr unsigned int TTO_DATA = 0xff << TTO_DATA_SHIFT; 37static constexpr std::uint_fast32_t TTO_DATA = 0xff << TTO_DATA_SHIFT;
29 38
30struct instruction_context { 39struct instruction_context {
31 // Known statically at decode time 40 // Known statically at decode time