diff --git a/cpu/ppc/ppcemu.h b/cpu/ppc/ppcemu.h index 481be6c..b9c8694 100644 --- a/cpu/ppc/ppcemu.h +++ b/cpu/ppc/ppcemu.h @@ -35,7 +35,7 @@ along with this program. If not, see . //#define ILLEGAL_OP_SAFE 1 // Uncomment this to use GCC built-in functions. -//#define USE_GCC_BUILTINS 1 +#define USE_GCC_BUILTINS 1 // Uncomment this to use Visual Studio built-in functions. //#define USE_VS_BUILTINS 1 diff --git a/cpu/ppc/ppcopcodes.cpp b/cpu/ppc/ppcopcodes.cpp index 21c3e21..70e81d3 100644 --- a/cpu/ppc/ppcopcodes.cpp +++ b/cpu/ppc/ppcopcodes.cpp @@ -516,15 +516,16 @@ void dppc_interpreter::ppc_neg() { void dppc_interpreter::ppc_cntlzw() { ppc_grab_regssa(); - uint32_t lead; uint32_t bit_check = ppc_result_d; #ifdef USE_GCC_BUILTINS - lead = !bit_check ? 32 : __builtin_clz(bit_check); + uint32_t lead = !bit_check ? 32 : __builtin_clz(bit_check); #elif defined USE_VS_BUILTINS - lead = __lzcnt(bit_check); + uint32_t lead = __lzcnt(bit_check); #else - for (uint32_t mask = 0x80000000UL, lead = 0; mask; lead++, mask >>= 1) { + uint32_t lead, mask; + + for (mask = 0x80000000UL, lead = 0; mask != 0; lead++, mask >>= 1) { if (bit_check & mask) break; }