From 9249960593e73c85cc5f61f4328c307e8547fc70 Mon Sep 17 00:00:00 2001 From: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> Date: Sun, 29 Apr 2018 03:25:01 +0200 Subject: [PATCH] Update Pseudocode.cs --- Ryujinx.Tests/Cpu/Tester/Pseudocode.cs | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Ryujinx.Tests/Cpu/Tester/Pseudocode.cs b/Ryujinx.Tests/Cpu/Tester/Pseudocode.cs index 72e0bd7804..18a1f4411c 100644 --- a/Ryujinx.Tests/Cpu/Tester/Pseudocode.cs +++ b/Ryujinx.Tests/Cpu/Tester/Pseudocode.cs @@ -104,6 +104,8 @@ namespace Ryujinx.Tests.Cpu.Tester SP_EL0.SetAll(false); /* SP_EL1 = bits(64) UNKNOWN; */ SP_EL1.SetAll(false); + + FPSR.SetAll(false); // FIXME: Temporary solution. } // #impl-aarch64.SP.write.0 @@ -518,6 +520,8 @@ namespace Ryujinx.Tests.Cpu.Tester SP_EL0 = new Bits(64, false); SP_EL1 = new Bits(64, false); + FPSR = new Bits(32, false); // FIXME: Temporary solution. + PSTATE.N = false; PSTATE.Z = false; PSTATE.C = false; @@ -1016,6 +1020,8 @@ namespace Ryujinx.Tests.Cpu.Tester public static Bits SP_EL0; public static Bits SP_EL1; + + public static Bits FPSR; // FIXME: Temporary solution. #endregion #region "functions/system/" @@ -1081,6 +1087,7 @@ namespace Ryujinx.Tests.Cpu.Tester return true; // EL1 and EL0 must exist } + /* return boolean IMPLEMENTATION_DEFINED; */ return false; } @@ -1113,5 +1120,65 @@ namespace Ryujinx.Tests.Cpu.Tester public bool SP; // Stack pointer select: 0=SP0, 1=SPx [AArch64 only] } #endregion + +#region "functions/vector/" + // #impl-shared.SatQ.3 + public static (Bits, bool) SatQ(BigInteger i, int N, bool unsigned) + { + (Bits result, bool sat) = (unsigned ? UnsignedSatQ(i, N) : SignedSatQ(i, N)); + + return (result, sat); + } + + // #impl-shared.SignedSatQ.2 + public static (Bits, bool) SignedSatQ(BigInteger i, int N) + { + BigInteger result; + bool saturated; + + if (i > BigInteger.Pow(2, N - 1) - 1) + { + result = BigInteger.Pow(2, N - 1) - 1; + saturated = true; + } + else if (i < -(BigInteger.Pow(2, N - 1))) + { + result = -(BigInteger.Pow(2, N - 1)); + saturated = true; + } + else + { + result = i; + saturated = false; + } + + return (result.SubBigInteger(N - 1, 0), saturated); + } + + // #impl-shared.UnsignedSatQ.2 + public static (Bits, bool) UnsignedSatQ(BigInteger i, int N) + { + BigInteger result; + bool saturated; + + if (i > BigInteger.Pow(2, N) - 1) + { + result = BigInteger.Pow(2, N) - 1; + saturated = true; + } + else if (i < 0) + { + result = 0; + saturated = true; + } + else + { + result = i; + saturated = false; + } + + return (result.SubBigInteger(N - 1, 0), saturated); + } +#endregion } }