From 0ff911cc261205f61079e14c7e2ba2be43c227db Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Wed, 27 Mar 2024 00:14:31 +0100 Subject: [PATCH] poweropcodes: cosmetic improvements. --- cpu/ppc/poweropcodes.cpp | 59 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/cpu/ppc/poweropcodes.cpp b/cpu/ppc/poweropcodes.cpp index 5c54513..9fc6332 100644 --- a/cpu/ppc/poweropcodes.cpp +++ b/cpu/ppc/poweropcodes.cpp @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-23 divingkatae and maximum +Copyright (C) 2018-24 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -136,8 +136,8 @@ template void dppc_interpreter::power_divs(); template void dppc_interpreter::power_doz() { ppc_grab_regsdab(ppc_cur_instruction); - uint32_t ppc_result_d = (int32_t(ppc_result_a) >= int32_t(ppc_result_b))\ - ? 0 : ppc_result_b - ppc_result_a; + uint32_t ppc_result_d = (int32_t(ppc_result_a) >= int32_t(ppc_result_b)) ? 0 : + ppc_result_b - ppc_result_a; if (rec) ppc_changecrf0(ppc_result_d); @@ -185,7 +185,7 @@ void dppc_interpreter::power_lscbx() { if (!shift_amount) { if (reg_d != reg_a && reg_d != reg_b) ppc_store_iresult_reg(reg_d, ppc_result_d); - reg_d = (reg_d + 1) & 31; + reg_d = (reg_d + 1) & 0x1F; bitmask = 0xFF000000; shift_amount = 24; } else { @@ -217,8 +217,8 @@ template void dppc_interpreter::power_lscbx(); template void dppc_interpreter::power_maskg() { ppc_grab_regssab(ppc_cur_instruction); - uint32_t mask_start = ppc_result_d & 31; - uint32_t mask_end = ppc_result_b & 31; + uint32_t mask_start = ppc_result_d & 0x1F; + uint32_t mask_end = ppc_result_b & 0x1F; uint32_t insert_mask = 0; if (mask_start < (mask_end + 1)) { @@ -298,9 +298,9 @@ template void dppc_interpreter::power_nabs(); void dppc_interpreter::power_rlmi() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_mb = (ppc_cur_instruction >> 6) & 31; - unsigned rot_me = (ppc_cur_instruction >> 1) & 31; - unsigned rot_sh = ppc_result_b & 31; + unsigned rot_mb = (ppc_cur_instruction >> 6) & 0x1F; + unsigned rot_me = (ppc_cur_instruction >> 1) & 0x1F; + unsigned rot_sh = ppc_result_b & 0x1F; uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); uint32_t mask = power_rot_mask(rot_mb, rot_me); @@ -335,7 +335,7 @@ template void dppc_interpreter::power_rrib(); template void dppc_interpreter::power_sle() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_sh = ppc_result_b & 31; + unsigned rot_sh = ppc_result_b & 0x1F; ppc_result_a = ppc_result_d << rot_sh; ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); @@ -354,7 +354,7 @@ template void dppc_interpreter::power_sle(); template void dppc_interpreter::power_sleq() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_sh = ppc_result_b & 31; + unsigned rot_sh = ppc_result_b & 0x1F; uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); uint32_t mask = power_rot_mask(0, 31 - rot_sh); @@ -373,7 +373,7 @@ template void dppc_interpreter::power_sleq(); template void dppc_interpreter::power_sliq() { ppc_grab_regssa(ppc_cur_instruction); - unsigned rot_sh = (ppc_cur_instruction >> 11) & 31; + unsigned rot_sh = (ppc_cur_instruction >> 11) & 0x1F; ppc_result_a = ppc_result_d << rot_sh; ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); @@ -390,9 +390,9 @@ template void dppc_interpreter::power_sliq(); template void dppc_interpreter::power_slliq() { ppc_grab_regssa(ppc_cur_instruction); - unsigned rot_sh = (ppc_cur_instruction >> 11) & 31; - uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); - uint32_t mask = power_rot_mask(0, 31 - rot_sh); + unsigned rot_sh = (ppc_cur_instruction >> 11) & 0x1F; + uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); + uint32_t mask = power_rot_mask(0, 31 - rot_sh); ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask)); ppc_state.spr[SPR::MQ] = r; @@ -409,9 +409,9 @@ template void dppc_interpreter::power_slliq(); template void dppc_interpreter::power_sllq() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_sh = ppc_result_b & 31; - uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); - uint32_t mask = power_rot_mask(0, 31 - rot_sh); + unsigned rot_sh = ppc_result_b & 0x1F; + uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); + uint32_t mask = power_rot_mask(0, 31 - rot_sh); if (ppc_result_b >= 0x20) { ppc_result_a = (ppc_state.spr[SPR::MQ] & mask); @@ -432,7 +432,7 @@ template void dppc_interpreter::power_sllq(); template void dppc_interpreter::power_slq() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_sh = ppc_result_b & 31; + unsigned rot_sh = ppc_result_b & 0x1F; if (ppc_result_b >= 0x20) { ppc_result_a = ppc_result_d << rot_sh; @@ -501,9 +501,9 @@ template void dppc_interpreter::power_sre() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_sh = ppc_result_b & 31; + unsigned rot_sh = ppc_result_b & 0x1F; + ppc_result_a = ppc_result_d >> rot_sh; - ppc_result_a = ppc_result_d >> rot_sh; ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)); if (rec) @@ -540,8 +540,8 @@ template void dppc_interpreter::power_srea(); template void dppc_interpreter::power_sreq() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_sh = ppc_result_b & 31; - unsigned mask = power_rot_mask(rot_sh, 31); + unsigned rot_sh = ppc_result_b & 0x1F; + unsigned mask = power_rot_mask(rot_sh, 31); ppc_result_a = ((rot_sh & mask) | (ppc_state.spr[SPR::MQ] & ~mask)); ppc_state.spr[SPR::MQ] = rot_sh; @@ -558,7 +558,7 @@ template void dppc_interpreter::power_sreq(); template void dppc_interpreter::power_sriq() { ppc_grab_regssa(ppc_cur_instruction); - unsigned rot_sh = (ppc_cur_instruction >> 11) & 31; + unsigned rot_sh = (ppc_cur_instruction >> 11) & 0x1F; ppc_result_a = ppc_result_d >> rot_sh; ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)); @@ -574,10 +574,9 @@ template void dppc_interpreter::power_sriq(); template void dppc_interpreter::power_srliq() { ppc_grab_regssa(ppc_cur_instruction); - unsigned rot_sh = (ppc_cur_instruction >> 11) & 31; - - uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)); - unsigned mask = power_rot_mask(rot_sh, 31); + unsigned rot_sh = (ppc_cur_instruction >> 11) & 0x1F; + uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)); + unsigned mask = power_rot_mask(rot_sh, 31); ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask)); ppc_state.spr[SPR::MQ] = r; @@ -594,7 +593,7 @@ template void dppc_interpreter::power_srliq(); template void dppc_interpreter::power_srlq() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_sh = ppc_result_b & 31; + unsigned rot_sh = ppc_result_b & 0x1F; uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)); unsigned mask = power_rot_mask(rot_sh, 31); @@ -617,7 +616,7 @@ template void dppc_interpreter::power_srlq(); template void dppc_interpreter::power_srq() { ppc_grab_regssab(ppc_cur_instruction); - unsigned rot_sh = ppc_result_b & 31; + unsigned rot_sh = ppc_result_b & 0x1F; if (ppc_result_b >= 0x20) { ppc_result_a = 0;