diff options
| author | Julian Blake Kongslie | 2022-10-29 18:18:26 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-10-29 18:18:26 -0700 |
| commit | 9f4aa97822adc791f700670ef0fc7636849563b7 (patch) | |
| tree | 0b9d6c1bb1d7d596501df3b77ab3d7b9f191aa4f /io/model.cpp | |
| parent | Control register values should not be "unsigned int" (diff) | |
| download | biggolf-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 'io/model.cpp')
| -rw-r--r-- | io/model.cpp | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/io/model.cpp b/io/model.cpp index 4b37be4..e9caba0 100644 --- a/io/model.cpp +++ b/io/model.cpp | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #include <array> | 1 | #include <array> |
| 2 | #include <cassert> | ||
| 2 | #include <cstdint> | 3 | #include <cstdint> |
| 3 | #include <iostream> | 4 | #include <iostream> |
| 4 | #include <utility> | 5 | #include <utility> |
| @@ -17,8 +18,7 @@ bool iomodel::interact(std::array<std::uint_fast32_t, NUM_CTLREGS> &ctlregs) { | |||
| 17 | ++time; | 18 | ++time; |
| 18 | 19 | ||
| 19 | if (ctlregs[TT_BITS] & TTO_TX) { | 20 | if (ctlregs[TT_BITS] & TTO_TX) { |
| 20 | // PDP-8 doesn't really have support for 8-bit output, this is Jules' contribution | 21 | std::cout << (char)(((ctlregs[TT_BITS] & TTO_DATA) >> TTO_DATA_SHIFT) & 0x7f) << std::flush; |
| 21 | std::cout << (char)(((ctlregs[TT_BITS] & TTO_DATA) >> TTO_DATA_SHIFT) ^ 0x80) << std::flush; | ||
| 22 | ctlregs[TT_BITS] &= ~TTO_TX & ~TTO_DATA; | 22 | ctlregs[TT_BITS] &= ~TTO_TX & ~TTO_DATA; |
| 23 | log.emplace(time + TT_OUTPUT_DELAY, event(TT_BITS, TTO_FLAG, 0)); | 23 | log.emplace(time + TT_OUTPUT_DELAY, event(TT_BITS, TTO_FLAG, 0)); |
| 24 | } | 24 | } |
| @@ -46,4 +46,42 @@ bool iomodel::interact(std::array<std::uint_fast32_t, NUM_CTLREGS> &ctlregs) { | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | return interrupt; | 48 | return interrupt; |
| 49 | }; | 49 | } |
| 50 | |||
| 51 | void iomodel::load_evt(std::istream &fh) { | ||
| 52 | // File format: | ||
| 53 | // +time advances time by relative increment | ||
| 54 | // regname=value/mask adds event that sets regname = (regname & ~mask) | value | ||
| 55 | // regname=value adds event that sets regname = value | ||
| 56 | // FIXME: add assertions | ||
| 57 | // FIXME: add DMA | ||
| 58 | for (std::string line; std::getline(fh, line); ) { | ||
| 59 | if (line.size() == 0) | ||
| 60 | continue; | ||
| 61 | if (line[0] == '+') { | ||
| 62 | char *end = nullptr; | ||
| 63 | auto step = std::strtoull(line.c_str(), &end, 0); | ||
| 64 | assert(end && *end == '\0'); | ||
| 65 | load_time += step; | ||
| 66 | } else { | ||
| 67 | auto eqpos = line.find('='); | ||
| 68 | assert(eqpos != std::string::npos); | ||
| 69 | auto regname = line.substr(0, eqpos); | ||
| 70 | ctlreg reg = ctlreg_map.at(regname); | ||
| 71 | std::uint_fast32_t value, mask; | ||
| 72 | auto slashpos = line.find('/', eqpos); | ||
| 73 | auto valuestr = line.substr(eqpos + 1, slashpos - (eqpos + 1)); | ||
| 74 | char *end = nullptr; | ||
| 75 | value = std::strtoull(valuestr.c_str(), &end, 0); | ||
| 76 | assert(end && *end == '\0'); | ||
| 77 | if (slashpos == std::string::npos) { | ||
| 78 | mask = ~(std::uint_fast32_t)0; | ||
| 79 | } else { | ||
| 80 | auto maskstr = line.substr(slashpos + 1); | ||
| 81 | mask = std::strtoull(maskstr.c_str(), &end, 0); | ||
| 82 | assert(end && *end == '\0'); | ||
| 83 | } | ||
| 84 | log.emplace(load_time, event(reg, value, mask)); | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
