summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-28 19:55:04 -0400
committerbd <bdunahu@operationnull.com>2025-03-28 19:55:04 -0400
commit7b3abbd51c91b51725a12d17fad6ecbfcdb19975 (patch)
tree4fdd60cc2de9f0a68814bf47d42d675593a965a0 /inc
parent9cd1f287f0c86b36788cd8ede812b847c584f711 (diff)
Move get_instr_fields, add all instruction mnemonics
Diffstat (limited to 'inc')
-rw-r--r--inc/id.h18
-rw-r--r--inc/instr.h47
-rw-r--r--inc/storage.h2
-rw-r--r--inc/utils.h18
4 files changed, 64 insertions, 21 deletions
diff --git a/inc/id.h b/inc/id.h
index eafe274..1503457 100644
--- a/inc/id.h
+++ b/inc/id.h
@@ -15,6 +15,24 @@ class ID : public Stage
ID(Stage *next);
Response advance(InstrDTO &i) override;
+
+ /**
+ * Parse an instruction into a type, opcode, and fields. If the type is
+ * invalid, only the type field will be set.
+ * @param the resulting first field, which varies per type. To call this
+ * function properly, this field must contain the full instruction bytes on
+ * function entry.
+ * @param the resulting second field, which varies per type.
+ * @param the resulting third field, which varies per type.
+ * @param the resulting type.
+ * @param the resulting opcode.
+ */
+ void get_instr_fields(
+ signed int &s1,
+ signed int &s2,
+ signed int &s3,
+ unsigned int &type,
+ unsigned int &opcode);
};
#endif /* ID_D_INCLUDED */
diff --git a/inc/instr.h b/inc/instr.h
index ce08685..98ecf1d 100644
--- a/inc/instr.h
+++ b/inc/instr.h
@@ -1,13 +1,56 @@
#ifndef INSTR_H
#define INSTR_H
-
#include <functional>
+#include <iostream>
#include <map>
+enum Mnemonic {
+ ADD,
+ SUB,
+ MUL,
+ QUOT,
+ REM,
+ SFTR,
+ SFTL,
+ AND,
+ OR,
+ NOT,
+ XOR,
+ ADDV,
+ SUBV,
+ MULV,
+ DIVV,
+ CMP,
+ CEV,
+ LOAD,
+ LOADV,
+ ADDI,
+ SUBI,
+ SFTRI,
+ SFTLI,
+ ANDI,
+ ORI,
+ XORI,
+ STORE,
+ STOREV,
+ JMP,
+ JRL,
+ JAL,
+ BEQ,
+ BGT,
+ BUF,
+ BOF,
+ PUSH,
+ POP,
+};
+
+std::ostream &operator<<(std::ostream &os, Mnemonic a);
+
namespace instr
{
// clang-format off
-extern const std::map<int,std::map<int,std::function<void(signed int &s1, signed int &s2, signed int &s3)>>> instr_map;
+ extern const std::map<unsigned int, Mnemonic> mnemonic_map;
+ extern const std::map<Mnemonic, std::function<void(signed int &s1, signed int &s2, signed int &s3)>> instr_map;
// clang-format on
} // namespace instr
diff --git a/inc/storage.h b/inc/storage.h
index ff1fbcb..d6fa094 100644
--- a/inc/storage.h
+++ b/inc/storage.h
@@ -80,7 +80,7 @@ class Storage
/**
* The accessor currently being serviced.
*/
- enum Accessor requester;
+ Accessor requester;
/**
* The number of cycles until the current request is completed.
*/
diff --git a/inc/utils.h b/inc/utils.h
index 7fed157..a375b68 100644
--- a/inc/utils.h
+++ b/inc/utils.h
@@ -13,24 +13,6 @@
void get_cache_fields(int address, int *tag, int *index, int *offset);
/**
- * Parse an instruction into a type, opcode, and fields. If the type is invalid,
- * only the type field will be set.
- * @param the resulting first field, which varies per type. To call this
- * function properly, this field must contain the full instruction bytes on
- * function entry.
- * @param the resulting second field, which varies per type.
- * @param the resulting third field, which varies per type.
- * @param the resulting type.
- * @param the resulting opcode.
- */
-void get_instr_fields(
- signed int &s1,
- signed int &s2,
- signed int &s3,
- unsigned int &type,
- unsigned int &opcode);
-
-/**
* Formats a string using snprintf.
* @param an object that represents the format string
* @param arguments to be formatted