Esempio n. 1
0
        protected void CompareAgainstUnicorn(
            Fpsr fpsrMask             = Fpsr.None,
            FpSkips fpSkips           = FpSkips.None,
            FpTolerances fpTolerances = FpTolerances.None)
        {
            if (!_unicornAvailable)
            {
                return;
            }

            if (fpSkips != FpSkips.None)
            {
                ManageFpSkips(fpSkips);
            }

            Assert.That(_context.GetX(0), Is.EqualTo(_unicornEmu.R[0]));
            Assert.That(_context.GetX(1), Is.EqualTo(_unicornEmu.R[1]));
            Assert.That(_context.GetX(2), Is.EqualTo(_unicornEmu.R[2]));
            Assert.That(_context.GetX(3), Is.EqualTo(_unicornEmu.R[3]));
            Assert.That(_context.GetX(4), Is.EqualTo(_unicornEmu.R[4]));
            Assert.That(_context.GetX(5), Is.EqualTo(_unicornEmu.R[5]));
            Assert.That(_context.GetX(6), Is.EqualTo(_unicornEmu.R[6]));
            Assert.That(_context.GetX(7), Is.EqualTo(_unicornEmu.R[7]));
            Assert.That(_context.GetX(8), Is.EqualTo(_unicornEmu.R[8]));
            Assert.That(_context.GetX(9), Is.EqualTo(_unicornEmu.R[9]));
            Assert.That(_context.GetX(10), Is.EqualTo(_unicornEmu.R[10]));
            Assert.That(_context.GetX(11), Is.EqualTo(_unicornEmu.R[11]));
            Assert.That(_context.GetX(12), Is.EqualTo(_unicornEmu.R[12]));
            Assert.That(_context.GetX(13), Is.EqualTo(_unicornEmu.R[13]));
            Assert.That(_context.GetX(14), Is.EqualTo(_unicornEmu.R[14]));

            if (fpTolerances == FpTolerances.None)
            {
                Assert.That(V128ToSimdValue(_context.GetV(0)), Is.EqualTo(_unicornEmu.Q[0]));
            }
            else
            {
                ManageFpTolerances(fpTolerances);
            }
            Assert.That(V128ToSimdValue(_context.GetV(1)), Is.EqualTo(_unicornEmu.Q[1]));
            Assert.That(V128ToSimdValue(_context.GetV(2)), Is.EqualTo(_unicornEmu.Q[2]));
            Assert.That(V128ToSimdValue(_context.GetV(3)), Is.EqualTo(_unicornEmu.Q[3]));
            Assert.That(V128ToSimdValue(_context.GetV(4)), Is.EqualTo(_unicornEmu.Q[4]));
            Assert.That(V128ToSimdValue(_context.GetV(5)), Is.EqualTo(_unicornEmu.Q[5]));
            Assert.That(V128ToSimdValue(_context.GetV(6)), Is.EqualTo(_unicornEmu.Q[6]));
            Assert.That(V128ToSimdValue(_context.GetV(7)), Is.EqualTo(_unicornEmu.Q[7]));
            Assert.That(V128ToSimdValue(_context.GetV(8)), Is.EqualTo(_unicornEmu.Q[8]));
            Assert.That(V128ToSimdValue(_context.GetV(9)), Is.EqualTo(_unicornEmu.Q[9]));
            Assert.That(V128ToSimdValue(_context.GetV(10)), Is.EqualTo(_unicornEmu.Q[10]));
            Assert.That(V128ToSimdValue(_context.GetV(11)), Is.EqualTo(_unicornEmu.Q[11]));
            Assert.That(V128ToSimdValue(_context.GetV(12)), Is.EqualTo(_unicornEmu.Q[12]));
            Assert.That(V128ToSimdValue(_context.GetV(13)), Is.EqualTo(_unicornEmu.Q[13]));
            Assert.That(V128ToSimdValue(_context.GetV(14)), Is.EqualTo(_unicornEmu.Q[14]));
            Assert.That(V128ToSimdValue(_context.GetV(15)), Is.EqualTo(_unicornEmu.Q[15]));

            Assert.That((int)_context.Fpcr | ((int)_context.Fpsr & (int)fpsrMask), Is.EqualTo(_unicornEmu.Fpscr));

            Assert.That(_context.GetPstateFlag(PState.VFlag), Is.EqualTo(_unicornEmu.OverflowFlag));
            Assert.That(_context.GetPstateFlag(PState.CFlag), Is.EqualTo(_unicornEmu.CarryFlag));
            Assert.That(_context.GetPstateFlag(PState.ZFlag), Is.EqualTo(_unicornEmu.ZeroFlag));
            Assert.That(_context.GetPstateFlag(PState.NFlag), Is.EqualTo(_unicornEmu.NegativeFlag));

            if (usingMemory)
            {
                byte[] meilleureMem = _memory.ReadBytes((long)(0x2000), _size);
                byte[] unicornMem   = _unicornEmu.MemoryRead((ulong)(0x2000), (ulong)_size);

                for (int i = 0; i < _size; i++)
                {
                    Assert.AreEqual(meilleureMem[i], unicornMem[i]);
                }
            }
        }
Esempio n. 2
0
        protected void CompareAgainstUnicorn(
            Fpsr fpsrMask             = Fpsr.None,
            FpSkips fpSkips           = FpSkips.None,
            FpTolerances fpTolerances = FpTolerances.None)
        {
            if (!_unicornAvailable)
            {
                return;
            }

            if (fpSkips != FpSkips.None)
            {
                ManageFpSkips(fpSkips);
            }

            Assert.That(_context.GetX(0), Is.EqualTo(_unicornEmu.R[0]), "R0");
            Assert.That(_context.GetX(1), Is.EqualTo(_unicornEmu.R[1]), "R1");
            Assert.That(_context.GetX(2), Is.EqualTo(_unicornEmu.R[2]), "R2");
            Assert.That(_context.GetX(3), Is.EqualTo(_unicornEmu.R[3]), "R3");
            Assert.That(_context.GetX(4), Is.EqualTo(_unicornEmu.R[4]));
            Assert.That(_context.GetX(5), Is.EqualTo(_unicornEmu.R[5]));
            Assert.That(_context.GetX(6), Is.EqualTo(_unicornEmu.R[6]));
            Assert.That(_context.GetX(7), Is.EqualTo(_unicornEmu.R[7]));
            Assert.That(_context.GetX(8), Is.EqualTo(_unicornEmu.R[8]));
            Assert.That(_context.GetX(9), Is.EqualTo(_unicornEmu.R[9]));
            Assert.That(_context.GetX(10), Is.EqualTo(_unicornEmu.R[10]));
            Assert.That(_context.GetX(11), Is.EqualTo(_unicornEmu.R[11]));
            Assert.That(_context.GetX(12), Is.EqualTo(_unicornEmu.R[12]));
            Assert.That(_context.GetX(13), Is.EqualTo(_unicornEmu.SP), "SP");
            Assert.That(_context.GetX(14), Is.EqualTo(_unicornEmu.R[14]));

            if (fpTolerances == FpTolerances.None)
            {
                Assert.That(V128ToSimdValue(_context.GetV(0)), Is.EqualTo(_unicornEmu.Q[0]), "V0");
            }
            else
            {
                ManageFpTolerances(fpTolerances);
            }
            Assert.That(V128ToSimdValue(_context.GetV(1)), Is.EqualTo(_unicornEmu.Q[1]), "V1");
            Assert.That(V128ToSimdValue(_context.GetV(2)), Is.EqualTo(_unicornEmu.Q[2]), "V2");
            Assert.That(V128ToSimdValue(_context.GetV(3)), Is.EqualTo(_unicornEmu.Q[3]), "V3");
            Assert.That(V128ToSimdValue(_context.GetV(4)), Is.EqualTo(_unicornEmu.Q[4]), "V4");
            Assert.That(V128ToSimdValue(_context.GetV(5)), Is.EqualTo(_unicornEmu.Q[5]), "V5");
            Assert.That(V128ToSimdValue(_context.GetV(6)), Is.EqualTo(_unicornEmu.Q[6]));
            Assert.That(V128ToSimdValue(_context.GetV(7)), Is.EqualTo(_unicornEmu.Q[7]));
            Assert.That(V128ToSimdValue(_context.GetV(8)), Is.EqualTo(_unicornEmu.Q[8]));
            Assert.That(V128ToSimdValue(_context.GetV(9)), Is.EqualTo(_unicornEmu.Q[9]));
            Assert.That(V128ToSimdValue(_context.GetV(10)), Is.EqualTo(_unicornEmu.Q[10]));
            Assert.That(V128ToSimdValue(_context.GetV(11)), Is.EqualTo(_unicornEmu.Q[11]));
            Assert.That(V128ToSimdValue(_context.GetV(12)), Is.EqualTo(_unicornEmu.Q[12]));
            Assert.That(V128ToSimdValue(_context.GetV(13)), Is.EqualTo(_unicornEmu.Q[13]));
            Assert.That(V128ToSimdValue(_context.GetV(14)), Is.EqualTo(_unicornEmu.Q[14]), "V14");
            Assert.That(V128ToSimdValue(_context.GetV(15)), Is.EqualTo(_unicornEmu.Q[15]), "V15");

            Assert.Multiple(() =>
            {
                Assert.That(_context.GetPstateFlag(PState.QFlag), Is.EqualTo(_unicornEmu.QFlag), "QFlag");
                Assert.That(_context.GetPstateFlag(PState.VFlag), Is.EqualTo(_unicornEmu.OverflowFlag), "VFlag");
                Assert.That(_context.GetPstateFlag(PState.CFlag), Is.EqualTo(_unicornEmu.CarryFlag), "CFlag");
                Assert.That(_context.GetPstateFlag(PState.ZFlag), Is.EqualTo(_unicornEmu.ZeroFlag), "ZFlag");
                Assert.That(_context.GetPstateFlag(PState.NFlag), Is.EqualTo(_unicornEmu.NegativeFlag), "NFlag");
            });

            Assert.That((int)GetFpscr() & (int)fpsrMask, Is.EqualTo(_unicornEmu.Fpscr & (int)fpsrMask), "Fpscr");

            if (_usingMemory)
            {
                byte[] mem        = _memory.GetSpan(DataBaseAddress, (int)Size).ToArray();
                byte[] unicornMem = _unicornEmu.MemoryRead(DataBaseAddress, Size);

                Assert.That(mem, Is.EqualTo(unicornMem), "Data");
            }
        }