Core: Update R4300iOp::COP1_S_MUL to handle exceptions

This commit is contained in:
zilmar 2023-03-21 10:49:49 +10:30
parent cbf67cede4
commit ce69324dbe
2 changed files with 68 additions and 45 deletions

View File

@ -2151,8 +2151,20 @@ void R4300iOp::COP1_S_MUL()
{ {
return; return;
} }
_FPCR[31] &= ~0x0003F000;
fesetround(*_RoundingModel); fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * *(float *)_FPR_S[m_Opcode.ft]); feclearexcept(FE_ALL_EXCEPT);
if (!CheckFPUInput32(*(float *)_FPR_S[m_Opcode.fs]) || !CheckFPUInput32(*(float *)_FPR_S[m_Opcode.ft]))
{
return;
}
float Result = (*(float *)_FPR_S[m_Opcode.fs] * *(float *)_FPR_S[m_Opcode.ft]);
if (CheckFPUException() || CheckFPUResult32(Result))
{
return;
}
*(uint32_t *)_FPR_S[m_Opcode.fd] = *(uint32_t *)&Result;
} }
void R4300iOp::COP1_S_DIV() void R4300iOp::COP1_S_DIV()
@ -2493,7 +2505,6 @@ void R4300iOp::COP1_D_SUB()
return; return;
} }
*(uint64_t *)_FPR_D[m_Opcode.fd] = *(uint64_t *)&Result; *(uint64_t *)_FPR_D[m_Opcode.fd] = *(uint64_t *)&Result;
} }
void R4300iOp::COP1_D_MUL() void R4300iOp::COP1_D_MUL()
@ -3040,6 +3051,17 @@ bool R4300iOp::CheckFPUException(void)
bool Res = false; bool Res = false;
FPStatusReg & StatusReg = (FPStatusReg &)_FPCR[31]; FPStatusReg & StatusReg = (FPStatusReg &)_FPCR[31];
if ((Except & FE_UNDERFLOW) != 0)
{
if (StatusReg.FlushSubnormals == 0 || StatusReg.Enable.Underflow || StatusReg.Enable.Inexact)
{
StatusReg.Cause.UnimplementedOperation = 1;
Res = true;
}
}
if (!Res)
{
if ((Except & FE_INEXACT) != 0) if ((Except & FE_INEXACT) != 0)
{ {
StatusReg.Cause.Inexact = 1; StatusReg.Cause.Inexact = 1;
@ -3100,6 +3122,7 @@ bool R4300iOp::CheckFPUException(void)
StatusReg.Flags.InvalidOperation = 1; StatusReg.Flags.InvalidOperation = 1;
} }
} }
}
if (Res) if (Res)
{ {
g_Reg->DoFloatingPointException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP); g_Reg->DoFloatingPointException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP);