All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Yongjun <yjwei@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>, kvm@vger.kernel.org
Subject: [PATCH] test: Add test for setcc instruction
Date: Fri, 06 Aug 2010 17:11:09 +0800	[thread overview]
Message-ID: <4C5BD1AD.10207@cn.fujitsu.com> (raw)

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>

diff --git a/x86/emulator.c b/x86/emulator.c
index e278812..5c8093e 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -375,6 +375,44 @@ void test_btc(void *mem)
 	report("btcl reg, r/m", a[0] == 1 && a[1] == 2 && a[2] == 0x80000004);
 }
 
+void test_setcc(void *mem)
+{
+	unsigned char *memb = mem;
+
+	asm ("seto %0":"=m"(*memb));
+	report("seto r/m8", *memb == 0);
+	asm ("setno %0":"=m"(*memb));
+	report("setno r/m8", *memb == 1);
+	asm ("setc %0":"=m"(*memb));
+	report("setc r/m8", *memb == 0);
+	asm ("setnc %0":"=m"(*memb));
+	report("setnc r/m8", *memb == 1);
+	asm ("sete %0":"=m"(*memb));
+	report("setz r/m8", *memb == 0);
+	asm ("setne %0":"=m"(*memb));
+	report("setnz r/m8", *memb == 1);
+	asm ("seta %0":"=m"(*memb));
+	report("seta r/m8", *memb == 1);
+	asm ("setna %0":"=m"(*memb));
+	report("setna r/m8", *memb == 0);
+	asm ("sets %0":"=m"(*memb));
+	report("sets r/m8", *memb == 0);
+	asm ("setns %0":"=m"(*memb));
+	report("setns r/m8", *memb == 1);
+	asm ("setp %0":"=m"(*memb));
+	report("setp r/m8", *memb == 0);
+	asm ("setnp %0":"=m"(*memb));
+	report("setnp r/m8", *memb == 1);
+	asm ("setl %0":"=m"(*memb));
+	report("setl r/m8", *memb == 0);
+	asm ("setnl %0":"=m"(*memb));
+	report("setnl r/m8", *memb == 1);
+	asm ("setle %0":"=m"(*memb));
+	report("setle r/m8", *memb == 0);
+	asm ("setnle %0":"=m"(*memb));
+	report("setnle r/m8", *memb == 1);
+}
+
 int main()
 {
 	void *mem;
@@ -407,6 +445,7 @@ int main()
 	test_stringio();
 	test_incdecnotneg(mem);
 	test_btc(mem);
+	test_setcc(mem);
 
 	printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
 	return fails ? 1 : 0;
-- 
1.7.0.4



             reply	other threads:[~2010-08-06  9:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-06  9:11 Wei Yongjun [this message]
2010-08-06 11:04 ` [PATCH] test: Add test for setcc instruction Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C5BD1AD.10207@cn.fujitsu.com \
    --to=yjwei@cn.fujitsu.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.