diff options
author | bd <bdunahu@operationnull.com> | 2025-04-17 17:20:48 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-17 17:20:48 -0400 |
commit | c7c531ce16fe66bf9f3bcb04ea9294d50a41e348 (patch) | |
tree | 4bc2b191f65352d951741d1deffa88492371609b /inc/ex.h | |
parent | f6f2f32b6dbd1b1e60052cb67f40864c3b5bd74b (diff) |
HALT instruction... but it voids future stages' instructions
Diffstat (limited to 'inc/ex.h')
-rw-r--r-- | inc/ex.h | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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; }; |