From eafc58c9f2e2e0c19d22f0da2a93ab5372aeef29 Mon Sep 17 00:00:00 2001 From: MS-DOS1999 Date: Fri, 23 Feb 2018 15:53:32 +0100 Subject: [PATCH] Add flags parameters in singleOpcode function, and add ADC Test (#36) * Add flags parameters in singleOpcode function, and add ADC Test * Update CpuTestAlu.cs * Update CpuTestAlu.cs * Update CpuTestAlu.cs * Update CpuTestAlu.cs --- Ryujinx.Tests/Cpu/CpuTest.cs | 12 +++++++++--- Ryujinx.Tests/Cpu/CpuTestAlu.cs | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Ryujinx.Tests/Cpu/CpuTest.cs b/Ryujinx.Tests/Cpu/CpuTest.cs index 949b9596..92c74e44 100644 --- a/Ryujinx.Tests/Cpu/CpuTest.cs +++ b/Ryujinx.Tests/Cpu/CpuTest.cs @@ -58,7 +58,8 @@ namespace Ryujinx.Tests.Cpu } protected void SetThreadState(ulong X0 = 0, ulong X1 = 0, ulong X2 = 0, - AVec V0 = default(AVec), AVec V1 = default(AVec), AVec V2 = default(AVec)) + AVec V0 = default(AVec), AVec V1 = default(AVec), AVec V2 = default(AVec), + bool Overflow = false, bool Carry = false, bool Zero = false, bool Negative = false) { Thread.ThreadState.X0 = X0; Thread.ThreadState.X1 = X1; @@ -66,6 +67,10 @@ namespace Ryujinx.Tests.Cpu Thread.ThreadState.V0 = V0; Thread.ThreadState.V1 = V1; Thread.ThreadState.V2 = V2; + Thread.ThreadState.Overflow = Overflow; + Thread.ThreadState.Carry = Carry; + Thread.ThreadState.Zero = Zero; + Thread.ThreadState.Negative = Negative; } protected void ExecuteOpcodes() @@ -87,12 +92,13 @@ namespace Ryujinx.Tests.Cpu protected AThreadState SingleOpcode(uint Opcode, ulong X0 = 0, ulong X1 = 0, ulong X2 = 0, - AVec V0 = default(AVec), AVec V1 = default(AVec), AVec V2 = default(AVec)) + AVec V0 = default(AVec), AVec V1 = default(AVec), AVec V2 = default(AVec), + bool Overflow = false, bool Carry = false, bool Zero = false, bool Negative = false) { this.Opcode(Opcode); this.Opcode(0xD4200000); // BRK #0 this.Opcode(0xD65F03C0); // RET - SetThreadState(X0, X1, X2, V0, V1, V2); + SetThreadState(X0, X1, X2, V0, V1, V2, Overflow, Carry, Zero, Negative); ExecuteOpcodes(); return GetThreadState(); diff --git a/Ryujinx.Tests/Cpu/CpuTestAlu.cs b/Ryujinx.Tests/Cpu/CpuTestAlu.cs index fd535725..b73212ac 100644 --- a/Ryujinx.Tests/Cpu/CpuTestAlu.cs +++ b/Ryujinx.Tests/Cpu/CpuTestAlu.cs @@ -5,6 +5,15 @@ namespace Ryujinx.Tests.Cpu { public class CpuTestAlu : CpuTest { + [TestCase(2u, 3u, 6ul, true)] + [TestCase(2u, 3u, 5ul, false)] + public void Adc(uint A, uint B, ulong Result, bool CarryTest) + { + // ADC X0, X1, X2 + AThreadState ThreadState = SingleOpcode(0x9A020020, X1: A, X2: B, Carry: CarryTest); + Assert.AreEqual(Result, ThreadState.X0); + } + [Test] public void Add() {