[PATCH] test: Add test for setcc instruction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Wei Yongjun <yjwei@xxxxxxxxxxxxxx>

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


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux