From 442c96103880bb276cb32d6c4ef2d33df6e3e457 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 14 Dec 2014 20:11:59 -0500 Subject: [PATCH] integer: Add CPU test for USAD8 --- source/tests/cpu/integer.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/tests/cpu/integer.cpp b/source/tests/cpu/integer.cpp index 4221946..d0d072a 100644 --- a/source/tests/cpu/integer.cpp +++ b/source/tests/cpu/integer.cpp @@ -127,6 +127,25 @@ static bool Uqsub8() { return true; } +// USAD8 +static bool Usad8() { + unsigned int output; + unsigned int rm = 50; + unsigned int rn = 10; + + // Regular subtraction + asm volatile ("USAD8 %[out], %[Rm], %[Rn]" : [out] "=r"(output) : [Rm] "r"(rm), [Rn] "r"(rn)); + SoftAssert(output == 40); + + // Absolute value subtraction (0 - 1) == 1 with USAD8. UCHAR_MAX rollover does not occur. + rm = 0; + rn = 1; + asm volatile ("USAD8 %[out], %[Rm], %[Rn]" : [out] "=r"(output) : [Rm] "r"(rm), [Rn] "r"(rn)); + SoftAssert(output == 1); + + return true; +} + // UXTAB16 static bool Uxtab16() { unsigned int output; @@ -188,6 +207,7 @@ void TestAll() { Test(tag, "SASX", Sasx(), true); Test(tag, "SSAX", Ssax(), true); Test(tag, "UQSUB8", Uqsub8(), true); + Test(tag, "USAD8", Usad8(), true); Test(tag, "UXTAB16", Uxtab16(), true); Test(tag, "UXTB16", Uxtb16(), true); }