diff options
Diffstat (limited to 'qtmips_machine')
-rw-r--r-- | qtmips_machine/cop0state.cpp | 5 | ||||
-rw-r--r-- | qtmips_machine/cop0state.h | 1 | ||||
-rw-r--r-- | qtmips_machine/registers.cpp | 14 | ||||
-rw-r--r-- | qtmips_machine/registers.h | 2 |
4 files changed, 17 insertions, 5 deletions
diff --git a/qtmips_machine/cop0state.cpp b/qtmips_machine/cop0state.cpp index 35f78d1..1caada1 100644 --- a/qtmips_machine/cop0state.cpp +++ b/qtmips_machine/cop0state.cpp @@ -150,7 +150,10 @@ QString Cop0State::cop0reg_name(enum Cop0Registers reg) { } std::uint32_t Cop0State::read_cop0reg_default(enum Cop0Registers reg) const { - return cop0reg[(int)reg]; + std::uint32_t val; + val = cop0reg[(int)reg]; + emit cop0reg_read(reg, val); + return val; } void Cop0State::write_cop0reg_default(enum Cop0Registers reg, std::uint32_t value) { diff --git a/qtmips_machine/cop0state.h b/qtmips_machine/cop0state.h index 0fd3d3f..a6af9a4 100644 --- a/qtmips_machine/cop0state.h +++ b/qtmips_machine/cop0state.h @@ -89,6 +89,7 @@ public: signals: void cop0reg_update(enum Cop0Registers reg, std::uint32_t val); + void cop0reg_read(enum Cop0Registers reg, std::uint32_t val) const; public slots: void set_interrupt_signal(uint irq_num, bool active); diff --git a/qtmips_machine/registers.cpp b/qtmips_machine/registers.cpp index fa9731a..ed27ec6 100644 --- a/qtmips_machine/registers.cpp +++ b/qtmips_machine/registers.cpp @@ -87,25 +87,31 @@ void Registers::pc_abs_jmp_28(std::uint32_t address) { } std::uint32_t Registers::read_gp(std::uint8_t i) const { + std::uint32_t value; SANITY_ASSERT(i < 32, QString("Trying to read from register ") + QString(i)); if (!i) // $0 always reads as 0 return 0; - return this->gp[i - 1]; + value = this->gp[i - 1]; + emit gp_read(i, value); + return value; } void Registers::write_gp(std::uint8_t i, std::uint32_t value) { SANITY_ASSERT(i < 32, QString("Trying to write to register ") + QString(i)); if (i == 0) // Skip write to $0 return; - emit gp_update(i, value); this->gp[i - 1] = value; + emit gp_update(i, value); } std::uint32_t Registers::read_hi_lo(bool is_hi) const { + std::uint32_t value; if (is_hi) - return hi; + value = hi; else - return lo; + value = lo; + emit hi_lo_read(is_hi, value); + return value; } void Registers::write_hi_lo(bool is_hi, std::uint32_t value) { diff --git a/qtmips_machine/registers.h b/qtmips_machine/registers.h index a4f7aa8..63aa266 100644 --- a/qtmips_machine/registers.h +++ b/qtmips_machine/registers.h @@ -67,6 +67,8 @@ signals: void pc_update(std::uint32_t val); void gp_update(std::uint8_t i, std::uint32_t val); void hi_lo_update(bool hi, std::uint32_t val); + void gp_read(std::uint8_t i, std::uint32_t val) const; + void hi_lo_read(bool hi, std::uint32_t val) const; private: std::uint32_t gp[31]; // general-purpose registers ($0 is intentionally skipped) |