summaryrefslogtreecommitdiff
path: root/src/sim/instr.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-27 20:30:18 -0400
committerbd <bdunahu@operationnull.com>2025-03-27 20:30:18 -0400
commiteaa87e9fcd90c00d6261cbdb854efb7a09467f1d (patch)
treee7f4cc05a30e5589f8bd70ddc49f420369adbb3c /src/sim/instr.cc
parent8d37d15ebd1221e3b1698abb3b051d9d0c044c93 (diff)
Instr, InstrDTO gets/sets, other structures required for decode
Diffstat (limited to 'src/sim/instr.cc')
-rw-r--r--src/sim/instr.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/sim/instr.cc b/src/sim/instr.cc
new file mode 100644
index 0000000..608b871
--- /dev/null
+++ b/src/sim/instr.cc
@@ -0,0 +1,30 @@
+#include "instr.h"
+#include <functional>
+#include <map>
+
+// clang-format off
+#define INIT_INSTRUCTION(type, opcode, body) \
+ {type, {{opcode, [](signed int &s1, signed int &s2, signed int &s3) { \
+ body; \
+ }}}}
+// clang-format on
+
+namespace instr
+{
+// clang-format off
+const std::map<int, std::map<int, std::function<void(signed int &s1, signed int &s2, signed int &s3)>>>
+ // clang-format on
+ instr_map = {
+
+ /* R type instructions */
+ // TODO these need to be WRAPPED with a function that sets overflow.
+ // future note to self, if these are more than 2 lines each, you're
+ // doing it wrong
+ INIT_INSTRUCTION(0b00, 0b00001, s3 = s1 + s2),
+ INIT_INSTRUCTION(0b00, 0b00010, s3 = s1 - s2),
+
+ /* I type instructions */
+
+ /* J type instructions */
+};
+} // namespace instr