From a928c679130c5e8b3e89e9730f8db0721813d576 Mon Sep 17 00:00:00 2001 From: joevt Date: Tue, 9 Apr 2024 02:29:13 -0700 Subject: [PATCH] poweropcodes: Fix sraq. If bit 26 of rB is set then the mask should be all ones. If bit 26 of rB is set then rA should be all ones or all zeros (depending on the sign bit of rA). --- cpu/ppc/poweropcodes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/ppc/poweropcodes.cpp b/cpu/ppc/poweropcodes.cpp index 1e7e441..a70d73f 100644 --- a/cpu/ppc/poweropcodes.cpp +++ b/cpu/ppc/poweropcodes.cpp @@ -521,8 +521,8 @@ template void dppc_interpreter::power_sraq() { ppc_grab_regssab(ppc_cur_instruction); unsigned rot_sh = ppc_result_b & 0x1F; - uint32_t mask = (1 << rot_sh) - 1; - ppc_result_a = (int32_t)ppc_result_d >> rot_sh; + uint32_t mask = (ppc_result_b & 0x20) ? -1 : (1 << rot_sh) - 1; + ppc_result_a = (int32_t)ppc_result_d >> ((ppc_result_b & 0x20) ? 31 : rot_sh); ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {