summaryrefslogtreecommitdiff
path: root/inc/ex.h
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-17 20:52:55 -0400
committerbd <bdunahu@operationnull.com>2025-04-17 20:52:55 -0400
commit496a08fbfafb8399c9addaf2501262fee228ffd6 (patch)
tree3e87aed03b50673c8e8c53dba98a45f32f979f48 /inc/ex.h
parent025cdd8e174fcf1a229355ecaf63861ac388fa63 (diff)
parent984ce6eef2e439955ff991f90c2b654be7c6c3f3 (diff)
Merge remote-tracking branch 'origin/bdunahu' into dev-sid
Diffstat (limited to 'inc/ex.h')
-rw-r--r--inc/ex.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/inc/ex.h b/inc/ex.h
index e4c9d2b..f63539c 100644
--- a/inc/ex.h
+++ b/inc/ex.h
@@ -3,8 +3,16 @@
#include "instrDTO.h"
#include "response.h"
#include "stage.h"
+#include <exception>
#include <unordered_map>
+class HaltException : public std::exception
+{
+ const char *what() const noexcept override {
+ return "";
+ }
+};
+
class EX : public Stage
{
public:
@@ -19,13 +27,22 @@ class EX : public Stage
private:
void advance_helper();
/**
+ * Wrapper for division functions, which detects HALT instructinos (division
+ * by 0).
+ * @param the numerator
+ * @param the denominator
+ * @param if the modulo operator should instead be used
+ */
+ void handle_divide(signed int &s1, signed int s2, bool is_mod);
+ /**
* Maps each mnemonic to a function which carries out the instruction's base
* logic.
* All instructions store the result into s1.
*/
std::unordered_map<
Mnemonic,
- std::function<void(signed int &s1, signed int s2, signed int s3, unsigned int pc)>>
+ std::function<void(
+ signed int &s1, signed int s2, signed int s3, unsigned int pc)>>
instr_map;
};