From c8d39d5ee52ca583094c33a9335afde5b32a11d6 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Fri, 21 Jan 2022 16:32:07 +0100 Subject: [PATCH] ppcopcodes: fix creqv emulation. --- cpu/ppc/ppcopcodes.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpu/ppc/ppcopcodes.cpp b/cpu/ppc/ppcopcodes.cpp index 970b728..725fbb4 100644 --- a/cpu/ppc/ppcopcodes.cpp +++ b/cpu/ppc/ppcopcodes.cpp @@ -1261,10 +1261,11 @@ void dppc_interpreter::ppc_crandc() { } void dppc_interpreter::ppc_creqv() { ppc_grab_regsdab(); - if (!((ppc_state.cr & (0x80000000UL >> reg_a)) ^ (ppc_state.cr & (0x80000000UL >> reg_b)))) { - ppc_state.cr |= (0x80000000UL >> reg_d); - } else { + uint8_t ir = (ppc_state.cr >> (31 - reg_a)) ^ (ppc_state.cr >> (31 - reg_b)); + if (ir & 1) { // compliment is implemented by swapping the following if/else bodies ppc_state.cr &= ~(0x80000000UL >> reg_d); + } else { + ppc_state.cr |= (0x80000000UL >> reg_d); } } void dppc_interpreter::ppc_crnand() {