From 2269a338f9e5ad7a29bef5ff73bbb4d72489a92e Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 10 May 2025 21:24:41 -0400 Subject: Fix off-by-one in CEV equal --- src/ex.cc | 10 ++++------ src/id.cc | 13 ++++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ex.cc b/src/ex.cc index 4fcda0a..066f584 100644 --- a/src/ex.cc +++ b/src/ex.cc @@ -221,17 +221,15 @@ void EX::handle_vector_operations( } break; case CEV: - + bool eq; + eq = true; for (i = 0; i < v_len; i++) { if (s1[i] != s2[i]) { + eq = false; break; } } - if (i == v_len) { - this->set_condition(EQ, true); - } else { - this->set_condition(EQ, false); - } + this->set_condition(EQ, eq); break; default: diff --git a/src/id.cc b/src/id.cc index 2645aeb..85637a6 100644 --- a/src/id.cc +++ b/src/id.cc @@ -52,7 +52,6 @@ void ID::get_instr_fields(signed int instr_bits) case 0b11: this->status = OK; } - } void ID::split_instr(signed int &raw, unsigned int &type, Mnemonic &m) @@ -91,8 +90,7 @@ void ID::decode_R_type(signed int &s1) { unsigned int s0b, s1b, s2b; signed int s2, s3; - Response r1, r2; - Response r3 = OK; + Response r1, r2, r3; s0b = REG_SIZE; s1b = s0b + REG_SIZE; @@ -102,10 +100,11 @@ void ID::decode_R_type(signed int &s1) s1 = GET_LS_BITS(s1, s0b); if (this->curr_instr->type == SI_INT) { - r1 = this->read_guard(s1, s1); - this->curr_instr->operands.integer.slot_one = s1; - r2 = this->read_guard(s2, s2); - this->curr_instr->operands.integer.slot_two = s2; + r1 = this->read_guard( + s1, this->curr_instr->operands.integer.slot_one); + r2 = this->read_guard( + s2, this->curr_instr->operands.integer.slot_two); + r3 = OK; } else { r1 = this->read_guard>( s1, this->curr_instr->operands.vector.slot_one); -- cgit v1.2.3