diff options
author | Karel Kočí <cynerd@email.cz> | 2017-11-21 22:01:52 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-11-21 22:01:52 +0100 |
commit | cd9e572b6523fac483ce1695ae1785fca075cc53 (patch) | |
tree | 06fddd51de93b35915e1b6beeecec364be2492b1 /qtmips_machine/registers.cpp | |
parent | 499a88621d12ff0cdcba1f8c796b7031d6adc649 (diff) | |
download | qtmips-cd9e572b6523fac483ce1695ae1785fca075cc53.tar.gz qtmips-cd9e572b6523fac483ce1695ae1785fca075cc53.tar.bz2 qtmips-cd9e572b6523fac483ce1695ae1785fca075cc53.zip |
Implement and test ADD
Diffstat (limited to 'qtmips_machine/registers.cpp')
-rw-r--r-- | qtmips_machine/registers.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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); +} |