diff options
author | bunnei <bunneidev@gmail.com> | 2014-12-26 03:46:54 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-12-26 03:46:54 +0100 |
commit | 254567056f98b0cef14268501af5793b5238b772 (patch) | |
tree | 781195d40162e3ae43314d1e41321bb4bb7e77e9 | |
parent | Merge pull request #340 from lioncash/whoops (diff) | |
parent | armemu: Implement SMLALD/SMLSLD (diff) | |
download | yuzu-254567056f98b0cef14268501af5793b5238b772.tar yuzu-254567056f98b0cef14268501af5793b5238b772.tar.gz yuzu-254567056f98b0cef14268501af5793b5238b772.tar.bz2 yuzu-254567056f98b0cef14268501af5793b5238b772.tar.lz yuzu-254567056f98b0cef14268501af5793b5238b772.tar.xz yuzu-254567056f98b0cef14268501af5793b5238b772.tar.zst yuzu-254567056f98b0cef14268501af5793b5238b772.zip |
-rw-r--r-- | src/core/arm/interpreter/armemu.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp index c4c09d1fb..449fd3640 100644 --- a/src/core/arm/interpreter/armemu.cpp +++ b/src/core/arm/interpreter/armemu.cpp @@ -6497,8 +6497,39 @@ L_stm_s_takeabort: return 1; } break; - case 0x74: - printf ("Unhandled v6 insn: smlald/smlsld\n"); + case 0x74: // SMLALD and SMLSLD + { + const u8 rm_idx = BITS(8, 11); + const u8 rn_idx = BITS(0, 3); + const u8 rdlo_idx = BITS(12, 15); + const u8 rdhi_idx = BITS(16, 19); + const bool do_swap = (BIT(5) == 1); + + const u32 rdlo_val = state->Reg[rdlo_idx]; + const u32 rdhi_val = state->Reg[rdhi_idx]; + const u32 rn_val = state->Reg[rn_idx]; + u32 rm_val = state->Reg[rm_idx]; + + if (do_swap) + rm_val = (((rm_val & 0xFFFF) << 16) | (rm_val >> 16)); + + const s32 product1 = (s16)(rn_val & 0xFFFF) * (s16)(rm_val & 0xFFFF); + const s32 product2 = (s16)((rn_val >> 16) & 0xFFFF) * (s16)((rm_val >> 16) & 0xFFFF); + s64 result; + + // SMLALD + if (BIT(6) == 0) { + result = (product1 + product2) + (s64)(rdlo_val | ((s64)rdhi_val << 32)); + } + // SMLSLD + else { + result = (product1 - product2) + (s64)(rdlo_val | ((s64)rdhi_val << 32)); + } + + state->Reg[rdlo_idx] = (result & 0xFFFFFFFF); + state->Reg[rdhi_idx] = ((result >> 32) & 0xFFFFFFFF); + return 1; + } break; case 0x75: printf ("Unhandled v6 insn: smmla/smmls/smmul\n"); |