diff options
Diffstat (limited to 'isa')
| -rw-r--r-- | isa/checker.h | 3 | ||||
| -rw-r--r-- | isa/ctlreg.def | 8 | ||||
| -rw-r--r-- | isa/decode.cpp | 22 | ||||
| -rw-r--r-- | isa/isa.h | 37 |
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 @@ | |||
| 1 | REG(DATA_INSTRUCTION_FIELD_BUFFER) // (df << 3) | if_buffer | ||
| 2 | REG(DATA_INSTRUCTION_FIELD_SAVED) // (df_saved << 3) | if_saved | ||
| 3 | REG(HALTED) | ||
| 4 | REG(INT_ENABLE) // (int_enable_delay << 1) | int_enable | ||
| 5 | REG(INT_PENDING) // only meaningful if interrupts disabled | ||
| 6 | REG(TT_BITS) // see TT[IO]_* consts in isa/isa.h | ||
| 7 | REG(TT_INPUT_INT_ENABLE) // (status_enable << 1) | (int_enable) | ||
| 8 | REG(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; |
| @@ -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 | ||
| 7 | enum ctlreg { | 9 | enum 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 | ||
| 17 | const char * const ctlreg_names[] = { | ||
| 18 | #define REG(N) #N, | ||
| 19 | #include "ctlreg.def" | ||
| 20 | #undef REG | ||
| 21 | }; | ||
| 22 | |||
| 23 | const 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 |
| 21 | static constexpr unsigned int TTI_FLAG = 1 << 0; | 30 | static constexpr std::uint_fast32_t TTI_FLAG = 1 << 0; |
| 22 | static constexpr unsigned int TTO_TX = 1 << 1; | 31 | static constexpr std::uint_fast32_t TTO_TX = 1 << 1; |
| 23 | static constexpr unsigned int TTO_FLAG = 1 << 2; | 32 | static constexpr std::uint_fast32_t TTO_FLAG = 1 << 2; |
| 24 | static constexpr unsigned int TTO_FLAG_OLD = 1 << 3; | 33 | static constexpr std::uint_fast32_t TTO_FLAG_OLD = 1 << 3; |
| 25 | static constexpr unsigned int TTI_DATA_SHIFT = 8; | 34 | static constexpr unsigned int TTI_DATA_SHIFT = 8; |
| 26 | static constexpr unsigned int TTO_DATA_SHIFT = 16; | 35 | static constexpr unsigned int TTO_DATA_SHIFT = 16; |
| 27 | static constexpr unsigned int TTI_DATA = 0xff << TTI_DATA_SHIFT; | 36 | static constexpr std::uint_fast32_t TTI_DATA = 0xff << TTI_DATA_SHIFT; |
| 28 | static constexpr unsigned int TTO_DATA = 0xff << TTO_DATA_SHIFT; | 37 | static constexpr std::uint_fast32_t TTO_DATA = 0xff << TTO_DATA_SHIFT; |
| 29 | 38 | ||
| 30 | struct instruction_context { | 39 | struct instruction_context { |
| 31 | // Known statically at decode time | 40 | // Known statically at decode time |
