From bd419912b5a38d59a853ca35d7f8900f59d0e2f9 Mon Sep 17 00:00:00 2001 From: joevt Date: Mon, 1 Jan 2024 04:43:46 -0800 Subject: [PATCH] ppcfpopcodes: Fix stfs*. It should try to convert its operand to a single precision floating point number at least. --- cpu/ppc/ppcfpopcodes.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cpu/ppc/ppcfpopcodes.cpp b/cpu/ppc/ppcfpopcodes.cpp index befbcbf..166de7a 100644 --- a/cpu/ppc/ppcfpopcodes.cpp +++ b/cpu/ppc/ppcfpopcodes.cpp @@ -779,7 +779,8 @@ void dppc_interpreter::ppc_stfs() { ppc_grab_regsfpsia(); ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); ppc_effective_address += (reg_a) ? val_reg_a : 0; - mmu_write_vmem(ppc_effective_address, uint32_t(ppc_state.fpr[reg_s].int64_r)); + float result = ppc_state.fpr[reg_s].dbl64_r; + mmu_write_vmem(ppc_effective_address, uint32_t(result)); } void dppc_interpreter::ppc_stfsu() { @@ -787,7 +788,8 @@ void dppc_interpreter::ppc_stfsu() { if (reg_a != 0) { ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); ppc_effective_address += val_reg_a; - mmu_write_vmem(ppc_effective_address, uint32_t(ppc_state.fpr[reg_s].int64_r)); + float result = ppc_state.fpr[reg_s].dbl64_r; + mmu_write_vmem(ppc_effective_address, uint32_t(result)); ppc_state.gpr[reg_a] = ppc_effective_address; } else { ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP); @@ -797,14 +799,16 @@ void dppc_interpreter::ppc_stfsu() { void dppc_interpreter::ppc_stfsx() { ppc_grab_regsfpsiab(); ppc_effective_address = (reg_a) ? val_reg_a + val_reg_b : val_reg_b; - mmu_write_vmem(ppc_effective_address, uint32_t(ppc_state.fpr[reg_s].int64_r)); + float result = ppc_state.fpr[reg_s].dbl64_r; + mmu_write_vmem(ppc_effective_address, uint32_t(result)); } void dppc_interpreter::ppc_stfsux() { ppc_grab_regsfpsiab(); if (reg_a) { ppc_effective_address = val_reg_a + val_reg_b; - mmu_write_vmem(ppc_effective_address, uint32_t(ppc_state.fpr[reg_s].int64_r)); + float result = ppc_state.fpr[reg_s].dbl64_r; + mmu_write_vmem(ppc_effective_address, uint32_t(result)); ppc_state.gpr[reg_a] = ppc_effective_address; } else { ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);