summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-10-08 00:39:15 -0700
committerJulian Blake Kongslie2022-10-08 00:39:15 -0700
commit85b34e1c9dc03585ec4f13f6241cd8f0ecaf9cd9 (patch)
tree0ec9a990fab8c06d0e2c6aa67447f3a8003aaf3d /main.cpp
parentMinor cleanup and some compilation fixes. (diff)
downloadbiggolf-85b34e1c9dc03585ec4f13f6241cd8f0ecaf9cd9.tar.xz
Trivial support for running the checker on an image.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..bc17427
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,28 @@
1#include <arpa/inet.h>
2#include <cstdint>
3#include <fmt/format.h>
4#include <iostream>
5
6#include "isa/checker.h"
7
8extern std::uint16_t _binary_build___image_bin_start[];
9extern std::uint16_t _binary_build___image_bin_end[];
10
11int main(int argc, const char *argv[]) {
12 checker checker;
13
14 unsigned int address = 0;
15 for (auto *src = _binary_build___image_bin_start; src < _binary_build___image_bin_end; ++src, ++address) {
16 auto word = ntohs(*src);
17 std::cout << fmt::format("mem[{:04o}] = {:04o}\n", address, word);
18 checker.mem.store(address, word);
19 }
20
21 while (!checker.halted) {
22 std::cout << fmt::format("{:04o}: ", checker.pc);
23 checker.execute();
24 std::cout << fmt::format("acc={:04o}\n", checker.acc);
25 }
26
27 return 0;
28}