From cd9e572b6523fac483ce1695ae1785fca075cc53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 21 Nov 2017 22:01:52 +0100 Subject: Implement and test ADD --- qtmips_machine/registers.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'qtmips_machine/registers.cpp') diff --git a/qtmips_machine/registers.cpp b/qtmips_machine/registers.cpp index 6b4ddd3..5bb852e 100644 --- a/qtmips_machine/registers.cpp +++ b/qtmips_machine/registers.cpp @@ -7,17 +7,17 @@ #define PC_INIT 0x80020000 ////////////////////////////////////////////////////////////////////////////// -Registers::Registers() { +Registers::Registers() : QObject() { this->pc = PC_INIT; // Initialize to beginning program section for (int i = 0; i < 31; i++) this->gp[i] = 0; this->hi = this->lo = 0; } -Registers::Registers(const Registers &orig) : Registers() { +Registers::Registers(const Registers &orig) : QObject() { this->pc = orig.read_pc(); for (int i = 0; i < 31; i++) - this->gp[i] = orig.read_gp(i); + this->gp[i] = orig.read_gp(i + 1); this->lo = orig.read_hi_lo(false); this->hi = orig.read_hi_lo(true); } @@ -74,7 +74,7 @@ void Registers::write_hi_lo(bool hi, std::uint32_t value) { this->lo = value; } -bool Registers::operator ==(const Registers &c) const { +bool Registers::operator==(const Registers &c) const { if (read_pc() != c.read_pc()) return false; for (int i = 0; i < 31; i++) @@ -86,3 +86,7 @@ bool Registers::operator ==(const Registers &c) const { return false; return true; } + +bool Registers::operator!=(const Registers &c) const { + return ! this->operator==(c); +} -- cgit v1.2.3