Skip to content

Commit

Permalink
Interpreter: Raise program exception on floating point exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JosJuice committed Oct 13, 2021
1 parent c3bcc67 commit 7f7748e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7f7748e

Please sign in to comment.