From 29a832c68d9b27329938df99440fd7297be38f8a Mon Sep 17 00:00:00 2001 From: joevt Date: Mon, 8 Apr 2024 21:50:27 -0700 Subject: [PATCH] ppcopcodes: Use < 0 instead of & 0x8000000. --- cpu/ppc/poweropcodes.cpp | 10 +++++----- cpu/ppc/ppcopcodes.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cpu/ppc/poweropcodes.cpp b/cpu/ppc/poweropcodes.cpp index 0424562..0bcfedd 100644 --- a/cpu/ppc/poweropcodes.cpp +++ b/cpu/ppc/poweropcodes.cpp @@ -281,7 +281,7 @@ template void dppc_interpreter::power_mul(); template void dppc_interpreter::power_nabs() { ppc_grab_regsda(ppc_cur_instruction); - uint32_t ppc_result_d = ppc_result_a & 0x80000000 ? ppc_result_a : -ppc_result_a; + uint32_t ppc_result_d = (int32_t(ppc_result_a) < 0) ? ppc_result_a : -ppc_result_a; if (rec) ppc_changecrf0(ppc_result_d); @@ -317,7 +317,7 @@ template void dppc_interpreter::power_rrib() { ppc_grab_regssab(ppc_cur_instruction); - if (ppc_result_d & 0x80000000) { + if (int32_t(ppc_result_d) < 0) { ppc_result_a |= ((ppc_result_d & 0x80000000) >> ppc_result_b); } else { ppc_result_a &= ~((ppc_result_d & 0x80000000) >> ppc_result_b); @@ -454,7 +454,7 @@ void dppc_interpreter::power_sraiq() { ppc_result_a = (int32_t)ppc_result_d >> rot_sh; ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)); - if ((ppc_result_d & 0x80000000UL) && (ppc_result_d & mask)) { + if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) { ppc_state.spr[SPR::XER] |= XER::CA; } else { ppc_state.spr[SPR::XER] &= ~XER::CA; @@ -477,7 +477,7 @@ void dppc_interpreter::power_sraq() { ppc_result_a = (int32_t)ppc_result_d >> rot_sh; ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); - if ((ppc_result_d & 0x80000000UL) && (ppc_result_d & mask)) { + if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) { ppc_state.spr[SPR::XER] |= XER::CA; } else { ppc_state.spr[SPR::XER] &= ~XER::CA; @@ -519,7 +519,7 @@ void dppc_interpreter::power_srea() { ppc_result_a = (int32_t)ppc_result_d >> rot_sh; ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))); - if ((ppc_result_d & 0x80000000UL) && (ppc_result_d & rot_sh)) { + if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & rot_sh)) { ppc_state.spr[SPR::XER] |= XER::CA; } else { ppc_state.spr[SPR::XER] &= ~XER::CA; diff --git a/cpu/ppc/ppcopcodes.cpp b/cpu/ppc/ppcopcodes.cpp index d42e26d..a219155 100644 --- a/cpu/ppc/ppcopcodes.cpp +++ b/cpu/ppc/ppcopcodes.cpp @@ -69,7 +69,7 @@ inline void ppc_carry_sub(uint32_t a, uint32_t b) { // Affects the XER register's SO and OV Bits inline void ppc_setsoov(uint32_t a, uint32_t b, uint32_t d) { - if ((a ^ b) & (a ^ d) & 0x80000000UL) { + if (int32_t((a ^ b) & (a ^ d)) < 0) { ppc_state.spr[SPR::XER] |= XER::SO | XER::OV; } else { ppc_state.spr[SPR::XER] &= ~XER::OV; @@ -533,7 +533,7 @@ void dppc_interpreter::ppc_divw() { if (!ppc_result_b) { // handle the "anything / 0" case ppc_result_d = 0; // tested on G4 in Mac OS X 10.4 and Open Firmware. - // ppc_result_d = (ppc_result_a & 0x80000000) ? -1 : 0; /* UNDOCUMENTED! */ + // ppc_result_d = (int32_t(ppc_result_a) < 0) ? -1 : 0; /* UNDOCUMENTED! */ if (ov) ppc_state.spr[SPR::XER] |= XER::SO | XER::OV; @@ -632,7 +632,7 @@ void dppc_interpreter::ppc_sraw() { } else { uint32_t shift = ppc_result_b & 0x1F; ppc_result_a = int32_t(ppc_result_d) >> shift; - if ((ppc_result_d & 0x80000000UL) && (ppc_result_d & ((1U << shift) - 1))) + if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & ((1U << shift) - 1))) ppc_state.spr[SPR::XER] |= XER::CA; } @@ -652,7 +652,7 @@ void dppc_interpreter::ppc_srawi() { // clear XER[CA] by default ppc_state.spr[SPR::XER] &= ~XER::CA; - if ((ppc_result_d & 0x80000000UL) && (ppc_result_d & ((1U << rot_sh) - 1))) + if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & ((1U << rot_sh) - 1))) ppc_state.spr[SPR::XER] |= XER::CA; ppc_result_a = int32_t(ppc_result_d) >> rot_sh;