aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Tests/Cpu/Tester/Types
diff options
context:
space:
mode:
authorLDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>2018-04-20 17:40:15 +0200
committergdkchan <gab.dark.100@gmail.com>2018-04-20 12:40:15 -0300
commit2ccd995cb27d95d056f8b6f270cb74012bfb7a33 (patch)
tree4c550626f7a352b0456edcaa22bf9d5d5bf87a9a /Ryujinx.Tests/Cpu/Tester/Types
parent03002f6537e3208e6951bc9092e958985e200c7d (diff)
Add ADDHN{2}, RADDHN{2}, SUBHN{2}, RSUBHN{2} (vector) instructions. Add 8 Tests. (#92)
* Update AOpCodeTable.cs * Update AInstEmitSimdArithmetic.cs * Update Pseudocode.cs * Update Instructions.cs * Update Bits.cs * Create CpuTestSimd.cs * Create CpuTestSimdReg.cs * Update CpuTestSimd.cs Provide a better supply of input values for the 20 Simd Tests. * Update CpuTestSimdReg.cs Provide a better supply of input values for the 20 Simd Tests. * Update AOpCodeTable.cs * Update AInstEmitSimdArithmetic.cs * Update CpuTestSimd.cs * Update CpuTestSimdReg.cs
Diffstat (limited to 'Ryujinx.Tests/Cpu/Tester/Types')
-rw-r--r--Ryujinx.Tests/Cpu/Tester/Types/Bits.cs81
1 files changed, 73 insertions, 8 deletions
diff --git a/Ryujinx.Tests/Cpu/Tester/Types/Bits.cs b/Ryujinx.Tests/Cpu/Tester/Types/Bits.cs
index f4ee966c..30d63264 100644
--- a/Ryujinx.Tests/Cpu/Tester/Types/Bits.cs
+++ b/Ryujinx.Tests/Cpu/Tester/Types/Bits.cs
@@ -15,14 +15,15 @@ namespace Ryujinx.Tests.Cpu.Tester.Types
public Bits(bool[] values) => bits = new BitArray(values);
public Bits(byte[] bytes) => bits = new BitArray(bytes);
public Bits(Bits bits) => this.bits = new BitArray(bits.bits);
- private Bits(BitArray bitArray) => bits = new BitArray(bitArray);
public Bits(int length) => bits = new BitArray(length);
public Bits(int length, bool defaultValue) => bits = new BitArray(length, defaultValue);
+ private Bits(BitArray bitArray) => bits = new BitArray(bitArray);
public Bits(ulong value) => bits = new BitArray(BitConverter.GetBytes(value));
public Bits(uint value) => bits = new BitArray(BitConverter.GetBytes(value));
public Bits(ushort value) => bits = new BitArray(BitConverter.GetBytes(value));
public Bits(byte value) => bits = new BitArray(new byte[1] {value});
+ private BitArray ToBitArray() => new BitArray(bits);
public ulong ToUInt64()
{
byte[] dst = new byte[8];
@@ -39,7 +40,22 @@ namespace Ryujinx.Tests.Cpu.Tester.Types
return BitConverter.ToUInt32(dst, 0);
}
- private BitArray ToBitArray() => new BitArray(bits);
+ public ushort ToUInt16()
+ {
+ byte[] dst = new byte[2];
+
+ bits.CopyTo(dst, 0);
+
+ return BitConverter.ToUInt16(dst, 0);
+ }
+ public byte ToByte()
+ {
+ byte[] dst = new byte[1];
+
+ bits.CopyTo(dst, 0);
+
+ return dst[0];
+ }
public bool this[int index] // ASL: "<>".
{
@@ -166,17 +182,66 @@ namespace Ryujinx.Tests.Cpu.Tester.Types
BigInteger dst;
- if (left.Count <= 32)
+ switch (left.Count)
{
- dst = left.ToUInt32() + right;
+ case 8: dst = left.ToByte() + right; break;
+ case 16: dst = left.ToUInt16() + right; break;
+ case 32: dst = left.ToUInt32() + right; break;
+ case 64: dst = left.ToUInt64() + right; break;
+
+ default: throw new ArgumentOutOfRangeException();
}
- else if (left.Count <= 64)
+
+ return dst.SubBigInteger(left.Count - 1, 0);
+ }
+ public static Bits operator +(Bits left, Bits right) // ASL: "+".
+ {
+ if (((object)left == null) || ((object)right == null))
{
- dst = left.ToUInt64() + right;
+ throw new ArgumentNullException();
}
- else
+
+ if (left.Count != right.Count)
{
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentException();
+ }
+
+ BigInteger dst;
+
+ switch (left.Count)
+ {
+ case 8: dst = left.ToByte() + (BigInteger)right.ToByte(); break;
+ case 16: dst = left.ToUInt16() + (BigInteger)right.ToUInt16(); break;
+ case 32: dst = left.ToUInt32() + (BigInteger)right.ToUInt32(); break;
+ case 64: dst = left.ToUInt64() + (BigInteger)right.ToUInt64(); break;
+
+ default: throw new ArgumentOutOfRangeException();
+ }
+
+ return dst.SubBigInteger(left.Count - 1, 0);
+ }
+ public static Bits operator -(Bits left, Bits right) // ASL: "-".
+ {
+ if (((object)left == null) || ((object)right == null))
+ {
+ throw new ArgumentNullException();
+ }
+
+ if (left.Count != right.Count)
+ {
+ throw new ArgumentException();
+ }
+
+ BigInteger dst;
+
+ switch (left.Count)
+ {
+ case 8: dst = left.ToByte() - (BigInteger)right.ToByte(); break;
+ case 16: dst = left.ToUInt16() - (BigInteger)right.ToUInt16(); break;
+ case 32: dst = left.ToUInt32() - (BigInteger)right.ToUInt32(); break;
+ case 64: dst = left.ToUInt64() - (BigInteger)right.ToUInt64(); break;
+
+ default: throw new ArgumentOutOfRangeException();
}
return dst.SubBigInteger(left.Count - 1, 0);