public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi.kivity@gmail.com>
To: Marcelo Tosatti <mtosatti@redhat.com>, Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org
Subject: [PATCH] emulator: simple ALU tests
Date: Fri,  4 Jan 2013 16:17:04 +0200	[thread overview]
Message-ID: <1357309024-11736-1-git-send-email-avi.kivity@gmail.com> (raw)

Signed-off-by: Avi Kivity <avi.kivity@gmail.com>
---
 x86/emulator.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/x86/emulator.c b/x86/emulator.c
index c39027a..a128e13 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -863,6 +863,31 @@ static void test_ltr(volatile uint16_t *mem)
     report("ltr", str() == tr && (*trp & busy_mask));
 }
 
+static void test_simplealu(u32 *mem)
+{
+    *mem = 0x1234;
+    asm("or %1, %0" : "+m"(*mem) : "r"(0x8001));
+    report("or", *mem == 0x9235);
+    asm("add %1, %0" : "+m"(*mem) : "r"(2));
+    report("add", *mem == 0x9237);
+    asm("xor %1, %0" : "+m"(*mem) : "r"(0x1111));
+    report("xor", *mem == 0x8326);
+    asm("sub %1, %0" : "+m"(*mem) : "r"(0x26));
+    report("sub", *mem == 0x8300);
+    asm("clc; adc %1, %0" : "+m"(*mem) : "r"(0x100));
+    report("adc(0)", *mem == 0x8400);
+    asm("stc; adc %1, %0" : "+m"(*mem) : "r"(0x100));
+    report("adc(0)", *mem == 0x8501);
+    asm("clc; sbb %1, %0" : "+m"(*mem) : "r"(0));
+    report("sbb(0)", *mem == 0x8501);
+    asm("stc; sbb %1, %0" : "+m"(*mem) : "r"(0));
+    report("sbb(1)", *mem == 0x8500);
+    asm("and %1, %0" : "+m"(*mem) : "r"(0xfe77));
+    report("and", *mem == 0x8400);
+    asm("test %1, %0" : "+m"(*mem) : "r"(0xf000));
+    report("test", *mem == 0x8400);
+}
+
 int main()
 {
 	void *mem;
@@ -889,6 +914,7 @@ int main()
 		     : "memory");
 	report("mov reg, r/m (1)", t2 == 0x123456789abcdef);
 
+	test_simplealu(mem);
 	test_cmps(mem);
 	test_scas(mem);
 
-- 
1.8.0.1


             reply	other threads:[~2013-01-04 14:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-04 14:17 Avi Kivity [this message]
2013-01-09 20:32 ` [PATCH] emulator: simple ALU tests Marcelo Tosatti

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=1357309024-11736-1-git-send-email-avi.kivity@gmail.com \
    --to=avi.kivity@gmail.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox