diff options
author | Karel Kočí <cynerd@email.cz> | 2017-11-21 22:37:59 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-11-21 22:37:59 +0100 |
commit | c4efaa81d4bf498c721db5cdbf932e7a3bcb0cae (patch) | |
tree | adffb9dfb4b0d020aa68484bca961c8f3083e5f7 /qtmips_machine/alu.cpp | |
parent | cd9e572b6523fac483ce1695ae1785fca075cc53 (diff) | |
download | qtmips-c4efaa81d4bf498c721db5cdbf932e7a3bcb0cae.tar.gz qtmips-c4efaa81d4bf498c721db5cdbf932e7a3bcb0cae.tar.bz2 qtmips-c4efaa81d4bf498c721db5cdbf932e7a3bcb0cae.zip |
Implement tests for few more arithmetic instructions
Diffstat (limited to 'qtmips_machine/alu.cpp')
-rw-r--r-- | qtmips_machine/alu.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/qtmips_machine/alu.cpp b/qtmips_machine/alu.cpp index 85bc804..912ccf5 100644 --- a/qtmips_machine/alu.cpp +++ b/qtmips_machine/alu.cpp @@ -8,15 +8,15 @@ std::uint32_t alu_operate(enum AluOp operation, std::uint32_t s, std::uint32_t t case ALU_OP_SRL: return t >> sa; case ALU_OP_SRA: - // TODO is this correct implementation? (Shouldn't we be masking top most bit?) - return (t >> sa) | (t & 0x80000000); + // TODO is this correct implementation? (Should we be masking top most bit?) + return ((t & 0x7fffffff) >> sa) | (t & 0x80000000); case ALU_OP_SLLV: return t << s; case ALU_OP_SRLV: return t >> s; case ALU_OP_SRAV: - // TODO is this correct implementation? (Shouldn't we be masking top most bit?) - return (t >> s) | (t & 0x80000000); + // TODO is this correct implementation? (Should we be masking top most bit?) + return ((t & 0x7fffffff) >> s) | (t & 0x80000000); case ALU_OP_ADD: if (s > (0xFFFFFFFF - t)) throw QTMIPS_EXCEPTION(Overflow, "ADD operation overflow/underflow", QString::number(s) + QString(" + ") + QString::number(t)); |