From: Mohammed Gamal Subject: [PATCH v2 2/3] test: Add real mode test for mul instruction Date: Sun, 8 Aug 2010 21:13:32 +0300 Message-ID: <1281291213-4691-2-git-send-email-m.gamal005@gmail.com> References: <1281291213-4691-1-git-send-email-m.gamal005@gmail.com> Cc: mtosatti@redhat.com, kvm@vger.kernel.org, Mohammed Gamal To: avi@redhat.com Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:58294 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753641Ab0HHSNu (ORCPT ); Sun, 8 Aug 2010 14:13:50 -0400 Received: by wwj40 with SMTP id 40so10846162wwj.1 for ; Sun, 08 Aug 2010 11:13:49 -0700 (PDT) In-Reply-To: <1281291213-4691-1-git-send-email-m.gamal005@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Mohammed Gamal --- x86/realmode.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) diff --git a/x86/realmode.c b/x86/realmode.c index 5878396..582d0be 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1060,6 +1060,50 @@ void test_imul() print_serial("imul Test 6: PASS\n"); } +void test_mul() +{ + struct regs inregs = { 0 }, outregs; + + MK_INSN(mul8, "mov $2, %al\n\t" + "mov $4, %cx\n\t" + "imul %cl\n\t"); + + MK_INSN(mul16, "mov $2, %ax\n\t" + "mov $4, %cx\n\t" + "imul %cx\n\t"); + + MK_INSN(mul32, "mov $2, %eax\n\t" + "mov $4, %ecx\n\t" + "imul %ecx\n\t"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_mul8, + insn_mul8_end - insn_mul8); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || (outregs.eax & 0xff) != 8) + print_serial("mul Test 1: FAIL\n"); + else + print_serial("mul Test 1: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_mul16, + insn_mul16_end - insn_mul16); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 8) + print_serial("mul Test 2: FAIL\n"); + else + print_serial("mul Test 2: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_mul32, + insn_mul32_end - insn_mul32); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 8) + print_serial("mul Test 3: FAIL\n"); + else + print_serial("mul Test 3: PASS\n"); +} + void realmode_start(void) { test_null(); @@ -1084,6 +1128,7 @@ void realmode_start(void) test_iret(); test_int(); test_imul(); + test_mul(); exit(0); } -- 1.7.0.4