From 71e2e98d07499c6d0f31596fec52cd8cef5813a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 5 Jan 2018 18:14:53 +0100 Subject: Implement machine restart --- qtmips_machine/registers.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'qtmips_machine/registers.cpp') 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); +} -- cgit v1.2.3