2018-02-23 12:29:20 +00:00
|
|
|
using ChocolArm64.State;
|
2018-02-16 00:04:38 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace Ryujinx.Tests.Cpu
|
|
|
|
{
|
2018-02-23 12:29:20 +00:00
|
|
|
public class CpuTestAlu : CpuTest
|
2018-02-16 00:04:38 +00:00
|
|
|
{
|
2018-02-23 14:53:32 +00:00
|
|
|
[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);
|
|
|
|
}
|
|
|
|
|
2018-02-16 00:04:38 +00:00
|
|
|
[Test]
|
|
|
|
public void Add()
|
|
|
|
{
|
|
|
|
// ADD X0, X1, X2
|
2018-02-18 19:28:07 +00:00
|
|
|
AThreadState ThreadState = SingleOpcode(0x8B020020, X1: 1, X2: 2);
|
|
|
|
Assert.AreEqual(3, ThreadState.X0);
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
|
2018-02-23 12:29:20 +00:00
|
|
|
[TestCase(0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFul, true, false)]
|
|
|
|
[TestCase(0xFFFFFFFFu, 0x00000000u, 0x00000000ul, false, true)]
|
|
|
|
[TestCase(0x12345678u, 0x7324A993u, 0x12240010ul, false, false)]
|
|
|
|
public void Ands(uint A, uint B, ulong Result, bool Negative, bool Zero)
|
2018-02-16 00:04:38 +00:00
|
|
|
{
|
|
|
|
// ANDS W0, W1, W2
|
|
|
|
uint Opcode = 0x6A020020;
|
2018-02-23 12:29:20 +00:00
|
|
|
AThreadState ThreadState = SingleOpcode(Opcode, X1: A, X2: B);
|
|
|
|
Assert.AreEqual(Result, ThreadState.X0);
|
|
|
|
Assert.AreEqual(Negative, ThreadState.Negative);
|
|
|
|
Assert.AreEqual(Zero, ThreadState.Zero);
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void OrrBitmasks()
|
|
|
|
{
|
|
|
|
// ORR W0, WZR, #0x01010101
|
|
|
|
Assert.AreEqual(0x01010101, SingleOpcode(0x3200C3E0).X0);
|
2018-02-23 12:29:20 +00:00
|
|
|
|
|
|
|
Reset();
|
|
|
|
|
2018-02-16 00:04:38 +00:00
|
|
|
// ORR W1, WZR, #0x00F000F0
|
|
|
|
Assert.AreEqual(0x00F000F0, SingleOpcode(0x320C8FE1).X1);
|
2018-02-23 12:29:20 +00:00
|
|
|
|
|
|
|
Reset();
|
|
|
|
|
2018-02-16 00:04:38 +00:00
|
|
|
// ORR W2, WZR, #1
|
|
|
|
Assert.AreEqual(0x00000001, SingleOpcode(0x320003E2).X2);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void RevX0X0()
|
|
|
|
{
|
|
|
|
// REV X0, X0
|
2018-02-18 19:28:07 +00:00
|
|
|
AThreadState ThreadState = SingleOpcode(0xDAC00C00, X0: 0xAABBCCDDEEFF1100);
|
|
|
|
Assert.AreEqual(0x0011FFEEDDCCBBAA, ThreadState.X0);
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void RevW1W1()
|
|
|
|
{
|
|
|
|
// REV W1, W1
|
2018-02-18 19:28:07 +00:00
|
|
|
AThreadState ThreadState = SingleOpcode(0x5AC00821, X1: 0x12345678);
|
|
|
|
Assert.AreEqual(0x78563412, ThreadState.X1);
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|