From 4313e1d817d2dac6cf4d5a4abe9ff44eb8905a3d Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Fri, 14 Oct 2022 12:59:52 -0700 Subject: Use automatic literal support in palbart; fix loader to ignore checksum --- main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 7d299ec..b6c136c 100644 --- a/main.cpp +++ b/main.cpp @@ -2,13 +2,15 @@ #include #include #include -#include +#include +#include +#include #include "isa/checker.h" extern std::uint8_t _binary_count_bin_start[]; -static const std::unordered_map programs = { +static const std::map programs = { { "count", _binary_count_bin_start } }; @@ -17,6 +19,7 @@ int load_program(checker &checker, const std::uint8_t *program) { bool comment = false; unsigned int field = 0; unsigned int address = 0; + std::optional> data; while (true) { auto b1 = *program++; if (comment) { @@ -33,10 +36,13 @@ int load_program(checker &checker, const std::uint8_t *program) { address = ((b1 & 0077) << 6) | *program++; } else if ((b1 & 0300) == 0000) { seen_non_leader = true; + if (data.has_value()) { + //std::cout << fmt::format("mem[{:06o}] = {:04o}\n", data->first, data->second); + checker.mem.store(data->first, data->second); + } auto a = field | address++; auto d = ((b1 & 0077) << 6) | *program++; - //std::cout << fmt::format("mem[{:06o}] = {:04o}\n", a, d); - checker.mem.store(a, d); + data = std::make_pair(a, d); } else if ((b1 & 0307) == 0300) { seen_non_leader = true; field = (b1 & 0070) << 3; -- cgit v1.2.3