Interpreter: Raise program exception on floating point exceptions

This commit is contained in:
JosJuice 2021-08-18 12:20:25 +02:00
parent c3bcc67653
commit 7f7748e181
2 changed files with 13 additions and 0 deletions

View File

@ -11,6 +11,7 @@
#include "Common/CommonTypes.h"
#include "Common/FloatUtils.h"
#include "Core/PowerPC/Gekko.h"
#include "Core/PowerPC/Interpreter/ExceptionUtils.h"
#include "Core/PowerPC/PowerPC.h"
constexpr double PPC_NAN = std::numeric_limits<double>::quiet_NaN();
@ -24,10 +25,18 @@ enum class FPCC
FU = 1, // ?
};
inline void CheckFPExceptions(UReg_FPSCR fpscr)
{
if (fpscr.FEX && (MSR.FE0 || MSR.FE1))
GenerateProgramException(ProgramExceptionCause::FloatingPoint);
}
inline void UpdateFPExceptionSummary(UReg_FPSCR* fpscr)
{
fpscr->VX = (fpscr->Hex & FPSCR_VX_ANY) != 0;
fpscr->FEX = ((fpscr->Hex >> 22) & (fpscr->Hex & FPSCR_ANY_E)) != 0;
CheckFPExceptions(*fpscr);
}
inline void SetFPException(UReg_FPSCR* fpscr, u32 mask)

View File

@ -167,6 +167,10 @@ void Interpreter::mtmsr(UGeckoInstruction inst)
}
MSR.Hex = rGPR[inst.RS];
// FE0/FE1 may have been set
CheckFPExceptions(FPSCR);
PowerPC::CheckExceptions();
m_end_block = true;
}