From fd81d7b04032602148739de3305ebb5c3728f902 Mon Sep 17 00:00:00 2001 From: joevt Date: Sun, 4 Feb 2024 03:23:24 -0800 Subject: [PATCH] ppcfpopcodes: Fix load float. Type casting an int to a float assigns the value of the int to the float which is not what is needed here. --- cpu/ppc/ppcfpopcodes.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cpu/ppc/ppcfpopcodes.cpp b/cpu/ppc/ppcfpopcodes.cpp index 8789bc7..8327680 100644 --- a/cpu/ppc/ppcfpopcodes.cpp +++ b/cpu/ppc/ppcfpopcodes.cpp @@ -681,18 +681,17 @@ void dppc_interpreter::ppc_lfs() { ppc_grab_regsfpdia(); ppc_effective_address = int32_t(int16_t(ppc_cur_instruction)); ppc_effective_address += (reg_a) ? val_reg_a : 0; - float result = (float)mmu_read_vmem(ppc_effective_address); - ppc_state.fpr[reg_d].dbl64_r = (double)result; + uint32_t result = mmu_read_vmem(ppc_effective_address); + ppc_state.fpr[reg_d].dbl64_r = *(float*)(&result); } - void dppc_interpreter::ppc_lfsu() { ppc_grab_regsfpdia(); if (reg_a) { ppc_effective_address = int32_t(int16_t(ppc_cur_instruction)); ppc_effective_address += (reg_a) ? val_reg_a : 0; - float result = (float)mmu_read_vmem(ppc_effective_address); - ppc_state.fpr[reg_d].dbl64_r = (double)result; + uint32_t result = mmu_read_vmem(ppc_effective_address); + ppc_state.fpr[reg_d].dbl64_r = *(float*)(&result); ppc_state.gpr[reg_a] = ppc_effective_address; } else { ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP); @@ -702,16 +701,16 @@ void dppc_interpreter::ppc_lfsu() { void dppc_interpreter::ppc_lfsx() { ppc_grab_regsfpdiab(); ppc_effective_address = (reg_a) ? val_reg_a + val_reg_b : val_reg_b; - float result = (float)mmu_read_vmem(ppc_effective_address); - ppc_state.fpr[reg_d].dbl64_r = (double)result; + uint32_t result = mmu_read_vmem(ppc_effective_address); + ppc_state.fpr[reg_d].dbl64_r = *(float*)(&result); } void dppc_interpreter::ppc_lfsux() { ppc_grab_regsfpdiab(); if (reg_a) { ppc_effective_address = val_reg_a + val_reg_b; - float result = (float)mmu_read_vmem(ppc_effective_address); - ppc_state.fpr[reg_d].dbl64_r = (double)result; + uint32_t result = mmu_read_vmem(ppc_effective_address); + ppc_state.fpr[reg_d].dbl64_r = *(float*)(&result); ppc_state.gpr[reg_a] = ppc_effective_address; } else { ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);