From cecc302373f3f0211f5d120fffa513f7189d60f2 Mon Sep 17 00:00:00 2001 From: angie Date: Thu, 6 Feb 2025 16:26:37 -0300 Subject: [PATCH 1/2] R5900: Fix decoding the `imm5` operand of the `viaddi` instruction as a signed value instead of decoding it as an unsigned one. --- CHANGELOG.md | 5 +++++ cplusplus/include/instructions/InstructionR5900.hpp | 2 +- cplusplus/src/instructions/InstructionR5900.cpp | 4 ++-- .../RabbitizerInstructionR5900_OperandType.c | 2 +- tests/c/instruction_checks/r5900_disasm.c | 2 ++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdeea2d..7ff6a48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- R5900: Fix decoding the `imm5` operand of the `viaddi` instruction as a signed + value instead of decoding it as an unsigned one. + ## [1.12.5] - 2024-12-16 ### Fixed diff --git a/cplusplus/include/instructions/InstructionR5900.hpp b/cplusplus/include/instructions/InstructionR5900.hpp index d481901..9030083 100644 --- a/cplusplus/include/instructions/InstructionR5900.hpp +++ b/cplusplus/include/instructions/InstructionR5900.hpp @@ -33,7 +33,7 @@ namespace rabbitizer { uint8_t GetR5900_l() const; uint8_t GetR5900_m() const; - uint8_t GetR5900_imm5() const; + int8_t GetR5900_imm5() const; }; }; diff --git a/cplusplus/src/instructions/InstructionR5900.cpp b/cplusplus/src/instructions/InstructionR5900.cpp index 0ef07c1..5a72994 100644 --- a/cplusplus/src/instructions/InstructionR5900.cpp +++ b/cplusplus/src/instructions/InstructionR5900.cpp @@ -113,6 +113,6 @@ uint8_t InstructionR5900::GetR5900_m() const { return RAB_INSTR_R5900_GET_m(&this->instr); } -uint8_t InstructionR5900::GetR5900_imm5() const { - return RAB_INSTR_R5900_GET_imm5(&this->instr); +int8_t InstructionR5900::GetR5900_imm5() const { + return RabbitizerUtils_From2Complement(RAB_INSTR_R5900_GET_imm5(&this->instr), 5); } diff --git a/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c b/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c index 36398a3..e9bf5f7 100644 --- a/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c +++ b/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c @@ -515,7 +515,7 @@ size_t RabbitizerOperandType_process_r5900_immediate5(const RabbitizerInstructio return immOverrideLength; } - number = RAB_INSTR_R5900_GET_imm5(self); + number = RabbitizerUtils_From2Complement(RAB_INSTR_R5900_GET_imm5(self), 5); if (RabbitizerConfig_Cfg.misc.omit0XOnSmallImm) { if (number > -10 && number < 10) { RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", number); diff --git a/tests/c/instruction_checks/r5900_disasm.c b/tests/c/instruction_checks/r5900_disasm.c index fa8c033..336ec13 100644 --- a/tests/c/instruction_checks/r5900_disasm.c +++ b/tests/c/instruction_checks/r5900_disasm.c @@ -40,6 +40,8 @@ const TestEntry test_entries[] = { TEST_ENTRY_C(0x4A820BFF, NULL, "viswr.y $vi2, ($vi1)"), TEST_ENTRY_C(0x4A420BFF, NULL, "viswr.z $vi2, ($vi1)"), TEST_ENTRY_C(0x4A220BFF, NULL, "viswr.w $vi2, ($vi1)"), + + TEST_ENTRY_C(0x4A0307B2, NULL, "viaddi $vi3, $vi0, -0x2"), }; size_t test_entries_len = ARRAY_COUNT(test_entries); From 9ae964d22501942ffe1c7e0378ddafc2e9a26593 Mon Sep 17 00:00:00 2001 From: angie Date: Thu, 6 Feb 2025 16:26:46 -0300 Subject: [PATCH 2/2] version bump --- CHANGELOG.md | 3 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- include/common/RabbitizerVersion.h | 2 +- pyproject.toml | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ff6a48..6a892c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.12.6] - 2025-02-06 + ### Fixed - R5900: Fix decoding the `imm5` operand of the `viaddi` instruction as a signed @@ -707,6 +709,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - First version [unreleased]: https://github.com/Decompollaborate/rabbitizer/compare/master...develop +[1.12.6]: https://github.com/Decompollaborate/rabbitizer/compare/1.12.5...1.12.6 [1.12.5]: https://github.com/Decompollaborate/rabbitizer/compare/1.12.4...1.12.5 [1.12.4]: https://github.com/Decompollaborate/rabbitizer/compare/1.12.3...1.12.4 [1.12.3]: https://github.com/Decompollaborate/rabbitizer/compare/1.12.2...1.12.3 diff --git a/Cargo.lock b/Cargo.lock index 22a1358..8854ff8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,7 +102,7 @@ dependencies = [ [[package]] name = "rabbitizer" -version = "1.12.5" +version = "1.12.6" dependencies = [ "cc", "glob", diff --git a/Cargo.toml b/Cargo.toml index d27d9cc..6af08e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "rabbitizer" # Version should be synced with include/common/RabbitizerVersion.h -version = "1.12.5" +version = "1.12.6" edition = "2021" authors = ["Anghelo Carvajal "] description = "MIPS instruction decoder" diff --git a/README.md b/README.md index 567c82e..b3f1894 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ cargo add rabbitizer Or you can add it manually to your `Cargo.toml`: ```toml -rabbitizer = "1.12.5" +rabbitizer = "1.12.6" ``` See this crate at . diff --git a/include/common/RabbitizerVersion.h b/include/common/RabbitizerVersion.h index 6ce10bc..ccd7487 100644 --- a/include/common/RabbitizerVersion.h +++ b/include/common/RabbitizerVersion.h @@ -14,7 +14,7 @@ extern "C" { // Header version #define RAB_VERSION_MAJOR 1 #define RAB_VERSION_MINOR 12 -#define RAB_VERSION_PATCH 5 +#define RAB_VERSION_PATCH 6 #define RAB_VERSION_STR RAB_STRINGIFY(RAB_VERSION_MAJOR) "." RAB_STRINGIFY(RAB_VERSION_MINOR) "." RAB_STRINGIFY(RAB_VERSION_PATCH) diff --git a/pyproject.toml b/pyproject.toml index af2a401..55b73ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ [project] name = "rabbitizer" # Version should be synced with include/common/RabbitizerVersion.h -version = "1.12.5" +version = "1.12.6" description = "MIPS instruction decoder" # license = "MIT" readme = "README.md"