diff --git a/Ryujinx.Tests/Cpu/CpuTest.cs b/Ryujinx.Tests/Cpu/CpuTest.cs index c37d024f72..1f7151ffe7 100644 --- a/Ryujinx.Tests/Cpu/CpuTest.cs +++ b/Ryujinx.Tests/Cpu/CpuTest.cs @@ -174,17 +174,34 @@ namespace Ryujinx.Tests.Cpu return GetThreadState(); } - protected void CompareAgainstUnicorn() + [Flags] + protected enum FPSR + { + None = 0, + + /// Invalid Operation cumulative floating-point exception bit. + IOC = 1 << 0, + /// Divide by Zero cumulative floating-point exception bit. + DZC = 1 << 1, + /// Overflow cumulative floating-point exception bit. + OFC = 1 << 2, + /// Underflow cumulative floating-point exception bit. + UFC = 1 << 3, + /// Inexact cumulative floating-point exception bit. + IXC = 1 << 4, + /// Input Denormal cumulative floating-point exception bit. + IDC = 1 << 7, + /// Cumulative saturation bit. + QC = 1 << 27 + } + + protected void CompareAgainstUnicorn(FPSR FpsrMask = FPSR.None) { if (!UnicornAvailable) { return; } - const int QCFlagBit = 27; // Cumulative saturation bit. - - int FpsrMask = 1 << QCFlagBit; - Assert.That(Thread.ThreadState.X0, Is.EqualTo(UnicornEmu.X[0])); Assert.That(Thread.ThreadState.X1, Is.EqualTo(UnicornEmu.X[1])); Assert.That(Thread.ThreadState.X2, Is.EqualTo(UnicornEmu.X[2])); @@ -253,8 +270,8 @@ namespace Ryujinx.Tests.Cpu Assert.That(Thread.ThreadState.V31, Is.EqualTo(UnicornEmu.Q[31])); Assert.That(Thread.ThreadState.V31, Is.EqualTo(UnicornEmu.Q[31])); - Assert.That(Thread.ThreadState.Fpcr, Is.EqualTo(UnicornEmu.Fpcr)); - Assert.That(Thread.ThreadState.Fpsr & FpsrMask, Is.EqualTo(UnicornEmu.Fpsr & FpsrMask)); + Assert.That(Thread.ThreadState.Fpcr, Is.EqualTo(UnicornEmu.Fpcr)); + Assert.That(Thread.ThreadState.Fpsr & (int)FpsrMask, Is.EqualTo(UnicornEmu.Fpsr & (int)FpsrMask)); Assert.That(Thread.ThreadState.Overflow, Is.EqualTo(UnicornEmu.OverflowFlag)); Assert.That(Thread.ThreadState.Carry, Is.EqualTo(UnicornEmu.CarryFlag));