diff options
author | Tom Stellard <tstellar@gmail.com> | 2010-12-28 18:08:19 -0800 |
---|---|---|
committer | Tom Stellard <tstellar@gmail.com> | 2010-12-28 18:08:19 -0800 |
commit | ef91611ca9f13a112b66b55ed81d70490801b58f (patch) | |
tree | 546adb976b6a989b705215457a59deacd199c83b | |
parent | 4850bd80e72383d7a860e3e2ec54a68e1b35ae72 (diff) |
emulator: Treat uninitialised temp regs as input regs
-rw-r--r-- | emulator.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/emulator.cpp b/emulator.cpp index 4c498cc..92a615c 100644 --- a/emulator.cpp +++ b/emulator.cpp @@ -57,7 +57,15 @@ emulator::get_value(register_address addr) unsigned int index = addr.to_int(); switch(addr.m_type) { - case REGISTER_TYPE_TEMP: return m_temp_regs[index]->clone(); + case REGISTER_TYPE_TEMP: + if (index < m_temp_regs.size() && m_temp_regs[index]) { + return m_temp_regs[index]->clone(); + } else { + /* The Temp register has never been written, which + * means it is actually an input register */ + return m_input_regs[index]->clone(); + } + break; case REGISTER_TYPE_CONST: { float_value * val = m_const_regs[index]; |