From 0835e6f9f474899bce7dd0c901b1119cc51cbfe4 Mon Sep 17 00:00:00 2001 From: dingusdev <52434309+dingusdev@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:23:03 -0700 Subject: [PATCH] Tweaking conditional branch instructions --- cpu/ppc/ppcopcodes.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cpu/ppc/ppcopcodes.cpp b/cpu/ppc/ppcopcodes.cpp index 65ef7d2..8bfe4f9 100644 --- a/cpu/ppc/ppcopcodes.cpp +++ b/cpu/ppc/ppcopcodes.cpp @@ -1142,7 +1142,7 @@ void dppc_interpreter::ppc_bc() { } if (l) - ppc_state.spr[SPR::LR] = ppc_state.pc + 4; + ppc_state.spr[SPR::LR] = uint32_t(ppc_state.pc + 4); } template void dppc_interpreter::ppc_bc(); @@ -1159,16 +1159,17 @@ void dppc_interpreter::ppc_bcctr() { uint32_t ctr = ppc_state.spr[SPR::CTR]; uint32_t new_ctr; + if (for601) { new_ctr = ctr - 1; - if (!(br_bo & 0x04)) { - ppc_state.spr[SPR::CTR] = new_ctr; /* decrement CTR */ - } - } - else { + if (!(br_bo & 0x04)) + ppc_state.spr[SPR::CTR] = new_ctr; + ctr_ok = (br_bo & 0x04) | ((new_ctr != 0) == !(br_bo & 0x02)); + } else { new_ctr = ctr; + ctr_ok = 1; } - ctr_ok = (br_bo & 0x04) | ((new_ctr != 0) == !(br_bo & 0x02)); + cnd_ok = (br_bo & 0x10) | (!(ppc_state.cr & (0x80000000UL >> br_bi)) == !(br_bo & 0x08)); if (ctr_ok && cnd_ok) { @@ -1177,7 +1178,7 @@ void dppc_interpreter::ppc_bcctr() { } if (l) - ppc_state.spr[SPR::LR] = ppc_state.pc + 4; + ppc_state.spr[SPR::LR] = uint32_t(ppc_state.pc + 4); } template void dppc_interpreter::ppc_bcctr(); @@ -1204,7 +1205,7 @@ void dppc_interpreter::ppc_bclr() { } if (l) - ppc_state.spr[SPR::LR] = ppc_state.pc + 4; + ppc_state.spr[SPR::LR] = uint32_t(ppc_state.pc + 4); } template void dppc_interpreter::ppc_bclr();