From: Avi Kivity Subject: [PATCH] Test non-repeated scas Date: Tue, 17 Aug 2010 19:37:27 +0300 Message-ID: <1282063047-19689-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:7256 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750837Ab0HQQh2 (ORCPT ); Tue, 17 Aug 2010 12:37:28 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7HGbSUn010555 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Aug 2010 12:37:28 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7HGbR7R001138 for ; Tue, 17 Aug 2010 12:37:28 -0400 Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Avi Kivity --- x86/emulator.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git a/x86/emulator.c b/x86/emulator.c index a302ffd..04adce7 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -121,6 +121,46 @@ void test_cmps(void *mem) test_cmps_one(m1, m2); } +void test_scas(void *mem) +{ + bool z; + void *di; + + *(ulong *)mem = 0x77665544332211; + + di = mem; + asm ("scasb; setz %0" : "=rm"(z), "+D"(di) : "a"(0xff11)); + report("scasb match", di == mem + 1 && z); + + di = mem; + asm ("scasb; setz %0" : "=rm"(z), "+D"(di) : "a"(0xff54)); + report("scasb mismatch", di == mem + 1 && !z); + + di = mem; + asm ("scasw; setz %0" : "=rm"(z), "+D"(di) : "a"(0xff2211)); + report("scasw match", di == mem + 2 && z); + + di = mem; + asm ("scasw; setz %0" : "=rm"(z), "+D"(di) : "a"(0xffdd11)); + report("scasw mismatch", di == mem + 2 && !z); + + di = mem; + asm ("scasl; setz %0" : "=rm"(z), "+D"(di) : "a"(0xff44332211ul)); + report("scasd match", di == mem + 4 && z); + + di = mem; + asm ("scasl; setz %0" : "=rm"(z), "+D"(di) : "a"(0x45332211)); + report("scasd mismatch", di == mem + 4 && !z); + + di = mem; + asm ("scasq; setz %0" : "=rm"(z), "+D"(di) : "a"(0x77665544332211ul)); + report("scasq match", di == mem + 8 && z); + + di = mem; + asm ("scasq; setz %0" : "=rm"(z), "+D"(di) : "a"(3)); + report("scasq mismatch", di == mem + 8 && !z); +} + void test_cr8(void) { unsigned long src, dst; @@ -506,6 +546,7 @@ int main() report("mov reg, r/m (1)", t2 == 0x123456789abcdef); test_cmps(mem); + test_scas(mem); test_push(mem); test_pop(mem); -- 1.7.1