From 8f99510af0227e4c53a82fb0a1b5028dcb6f3ff4 Mon Sep 17 00:00:00 2001 From: dingusdev <52434309+dingusdev@users.noreply.github.com> Date: Tue, 15 Nov 2022 07:40:37 -0700 Subject: [PATCH] Fixed lscbx --- cpu/ppc/poweropcodes.cpp | 41 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/cpu/ppc/poweropcodes.cpp b/cpu/ppc/poweropcodes.cpp index 8a6c15b..c46ca88 100644 --- a/cpu/ppc/poweropcodes.cpp +++ b/cpu/ppc/poweropcodes.cpp @@ -137,7 +137,7 @@ void dppc_interpreter::power_dozi() { void dppc_interpreter::power_lscbx() { ppc_grab_regsdab(); ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b; - ppc_result_d = 0xFFFFFFFF; + //ppc_result_d = 0xFFFFFFFF; uint8_t return_value = 0; uint32_t bytes_to_load = (ppc_state.spr[SPR::XER] & 0x7f); @@ -148,25 +148,28 @@ void dppc_interpreter::power_lscbx() { uint32_t bitmask = 0xFF000000; uint8_t shift_amount = 24; - while (return_value != matching_byte) { - if (bytes_to_load > 0) { - return_value = mmu_read_vmem(ppc_effective_address); - // return_value = mem_grab_byte(ppc_effective_address); - ppc_result_d = (ppc_result_d & ~(bitmask)) | (return_value << shift_amount); - ppc_store_result_regd(); - if (bitmask == 0x000000FF) { - reg_d = (reg_d + 1) & 31; - ppc_result_d = 0xFFFFFFFF; - bitmask = 0xFF000000; - shift_amount = 24; - } else { - bitmask >>= 8; - shift_amount -= 8; - } - ppc_effective_address++; - bytes_copied++; - bytes_to_load--; + while (bytes_to_load > 0) { + return_value = mmu_read_vmem(ppc_effective_address); + // return_value = mem_grab_byte(ppc_effective_address); + ppc_result_d = (ppc_result_d & ~(bitmask)) | (return_value << shift_amount); + ppc_store_result_regd(); + if (bitmask == 0x000000FF) { + reg_d = (reg_d + 1) & 31; + //ppc_result_d = 0xFFFFFFFF; + bitmask = 0xFF000000; + shift_amount = 24; + } + else { + bitmask >>= 8; + shift_amount -= 8; } + + if (return_value == matching_byte) + break; + + ppc_effective_address++; + bytes_copied++; + bytes_to_load--; } ppc_state.spr[SPR::XER] = (ppc_state.spr[SPR::XER] & 0xFFFFFF80) | bytes_copied;