diff mbox

test: Add real mode test for cbw/cwde instruction

Message ID 4C6B9D7A.70301@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Yongjun Aug. 18, 2010, 8:44 a.m. UTC
None
diff mbox

Patch

diff --git a/x86/realmode.c b/x86/realmode.c
index bedd175..ce8fb18 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1236,6 +1236,32 @@  void test_loopcc(void)
 		print_serial("LOOPcc short Test 3: PASS\n");
 }
 
+void test_cbw(void)
+{
+	struct regs inregs = { 0 }, outregs;
+
+	MK_INSN(cbw, "mov $0xFE, %eax \n\t"
+		     "cbw\n\t");
+	MK_INSN(cwde, "mov $0xFFFE, %eax \n\t"
+		      "cwde\n\t");
+
+	exec_in_big_real_mode(&inregs, &outregs,
+			      insn_cbw,
+			      insn_cbw_end - insn_cbw);
+	if (outregs.eax != 0xFFFE)
+		print_serial("cbw test1: FAIL\n");
+	else
+		print_serial("cbw test 1: PASS\n");
+
+	exec_in_big_real_mode(&inregs, &outregs,
+			      insn_cwde,
+			      insn_cwde_end - insn_cwde);
+	if (outregs.eax != 0xFFFFFFFE)
+		print_serial("cwde test1: FAIL\n");
+	else
+		print_serial("cwde test 1: PASS\n");
+}
+
 void realmode_start(void)
 {
 	test_null();
@@ -1264,6 +1290,7 @@  void realmode_start(void)
 	test_div();
 	test_idiv();
 	test_loopcc();
+	test_cbw();
 
 	exit(0);
 }