aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/registers.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-01-05 18:14:53 +0100
committerKarel Kočí <cynerd@email.cz>2018-01-05 18:14:53 +0100
commit71e2e98d07499c6d0f31596fec52cd8cef5813a9 (patch)
treed2aa2729956464f2aab62bb5f088850b69a5a8d7 /qtmips_machine/registers.cpp
parent1a3fbaf22975b1f130998841adb3109b8a543513 (diff)
downloadqtmips-71e2e98d07499c6d0f31596fec52cd8cef5813a9.tar.gz
qtmips-71e2e98d07499c6d0f31596fec52cd8cef5813a9.tar.bz2
qtmips-71e2e98d07499c6d0f31596fec52cd8cef5813a9.zip
Implement machine restart
Diffstat (limited to 'qtmips_machine/registers.cpp')
-rw-r--r--qtmips_machine/registers.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/qtmips_machine/registers.cpp b/qtmips_machine/registers.cpp
index 447fdfc..5a720f7 100644
--- a/qtmips_machine/registers.cpp
+++ b/qtmips_machine/registers.cpp
@@ -10,10 +10,7 @@ using namespace machine;
//////////////////////////////////////////////////////////////////////////////
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;
+ reset();
}
Registers::Registers(const Registers &orig) : QObject() {
@@ -99,3 +96,11 @@ bool Registers::operator==(const Registers &c) const {
bool Registers::operator!=(const Registers &c) const {
return ! this->operator==(c);
}
+
+void Registers::reset() {
+ pc_abs_jmp(PC_INIT); // Initialize to beginning program section
+ for (int i = 1; i < 32; i++)
+ write_gp(i, 0);
+ write_hi_lo(false, 0);
+ write_hi_lo(true, 0);
+}