From c7c531ce16fe66bf9f3bcb04ea9294d50a41e348 Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 17 Apr 2025 17:20:48 -0400 Subject: HALT instruction... but it voids future stages' instructions --- inc/ex.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'inc/ex.h') 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 #include +class HaltException : public std::exception +{ + const char *what() const noexcept override { + return ""; + } +}; + class EX : public Stage { public: @@ -18,6 +26,14 @@ 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. @@ -25,7 +41,8 @@ class EX : public Stage */ std::unordered_map< Mnemonic, - std::function> + std::function> instr_map; }; -- cgit v1.2.3