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
This commit is contained in:
MS-DOS1999 2018-02-23 15:53:32 +01:00 committed by gdkchan
parent f09a0082bf
commit eafc58c9f2
2 changed files with 18 additions and 3 deletions

View File

@ -58,7 +58,8 @@ namespace Ryujinx.Tests.Cpu
} }
protected void SetThreadState(ulong X0 = 0, ulong X1 = 0, ulong X2 = 0, 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.X0 = X0;
Thread.ThreadState.X1 = X1; Thread.ThreadState.X1 = X1;
@ -66,6 +67,10 @@ namespace Ryujinx.Tests.Cpu
Thread.ThreadState.V0 = V0; Thread.ThreadState.V0 = V0;
Thread.ThreadState.V1 = V1; Thread.ThreadState.V1 = V1;
Thread.ThreadState.V2 = V2; Thread.ThreadState.V2 = V2;
Thread.ThreadState.Overflow = Overflow;
Thread.ThreadState.Carry = Carry;
Thread.ThreadState.Zero = Zero;
Thread.ThreadState.Negative = Negative;
} }
protected void ExecuteOpcodes() protected void ExecuteOpcodes()
@ -87,12 +92,13 @@ namespace Ryujinx.Tests.Cpu
protected AThreadState SingleOpcode(uint Opcode, protected AThreadState SingleOpcode(uint Opcode,
ulong X0 = 0, ulong X1 = 0, ulong X2 = 0, 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(Opcode);
this.Opcode(0xD4200000); // BRK #0 this.Opcode(0xD4200000); // BRK #0
this.Opcode(0xD65F03C0); // RET this.Opcode(0xD65F03C0); // RET
SetThreadState(X0, X1, X2, V0, V1, V2); SetThreadState(X0, X1, X2, V0, V1, V2, Overflow, Carry, Zero, Negative);
ExecuteOpcodes(); ExecuteOpcodes();
return GetThreadState(); return GetThreadState();

View File

@ -5,6 +5,15 @@ namespace Ryujinx.Tests.Cpu
{ {
public class CpuTestAlu : CpuTest 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] [Test]
public void Add() public void Add()
{ {