]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
A test for JECXZ and JCXZ.
authorJulian Seward <jseward@acm.org>
Thu, 16 Nov 2006 11:01:48 +0000 (11:01 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 16 Nov 2006 11:01:48 +0000 (11:01 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6355

none/tests/x86/Makefile.am
none/tests/x86/jcxz.c [new file with mode: 0644]
none/tests/x86/jcxz.stderr.exp [new file with mode: 0644]
none/tests/x86/jcxz.stdout.exp [new file with mode: 0644]
none/tests/x86/jcxz.vgtest [new file with mode: 0644]

index 508b27f659ba30d7e88392a8f253fdac7cd24802..f73ea835c399bc9f85fd72e5b5dd6bdb452e1a4e 100644 (file)
@@ -24,6 +24,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        $(addsuffix .stderr.exp,$(INSN_TESTS)) \
        $(addsuffix .stdout.exp,$(INSN_TESTS)) \
        $(addsuffix .vgtest,$(INSN_TESTS)) \
+       jcxz.stdout.exp jcxz.stderr.exp jcxz.vgtest \
        lahf.stdout.exp lahf.stderr.exp lahf.vgtest \
        looper.stderr.exp looper.stdout.exp looper.vgtest \
        movx.stderr.exp movx.stdout.exp movx.vgtest \
@@ -42,6 +43,7 @@ check_PROGRAMS = \
        cmpxchg8b cpuid \
        faultstatus fcmovnu fpu_lazy_eflags fxtract \
        getseg incdec_alt $(INSN_TESTS) \
+       jcxz \
        lahf looper movx int pushpopseg sbbmisc \
        seg_override sigcontext smc1 yield
 
diff --git a/none/tests/x86/jcxz.c b/none/tests/x86/jcxz.c
new file mode 100644 (file)
index 0000000..945dbdf
--- /dev/null
@@ -0,0 +1,54 @@
+
+#include <stdio.h>
+
+typedef  unsigned int  UInt;
+
+UInt test_jcxz ( UInt arg )
+{
+   UInt block[2];
+   block[0] = arg;
+   block[1] = 0xdeadbeef;
+   __asm__ __volatile__(
+      "movl %0,%%ecx\n\t"
+      "movl $0,%%eax\n"
+      ".Lxyzzy1:\n\t"
+      "jcxz .Lfoobar1\n\t"
+      "addl $1, %%eax\n\t"
+      "subl $1, %%ecx\n\t"
+      "jmp .Lxyzzy1\n"
+      ".Lfoobar1:\n\t"
+      "movl %%eax, %1"
+      : /*out*/ : /*in*/ "m"(block[0]),
+                         "m"(block[1]) : /*trash*/ "eax","ecx","cc","memory"
+   );
+   return block[1];
+}
+
+UInt test_jecxz ( UInt arg )
+{
+   UInt block[2];
+   block[0] = arg;
+   block[1] = 0xdeadbeef;
+   __asm__ __volatile__(
+      "movl %0,%%ecx\n\t"
+      "movl $0,%%eax\n"
+      ".Lxyzzy2:\n\t"
+      "jecxz .Lfoobar2\n\t"
+      "addl $1, %%eax\n\t"
+      "subl $1, %%ecx\n\t"
+      "jmp .Lxyzzy2\n"
+      ".Lfoobar2:\n\t"
+      "movl %%eax, %1"
+      : /*out*/ : /*in*/ "m"(block[0]),
+                         "m"(block[1]) : /*trash*/ "eax","ecx","cc","memory"
+   );
+   return block[1];
+}
+
+int main ( void )
+{
+   UInt arg = 0x01028374;
+   printf("test_jcxz(0x%x)  = 0x%x\n", arg, test_jcxz(arg));
+   printf("test_jecxz(0x%x) = 0x%x\n", arg, test_jecxz(arg));
+   return 0;
+}
diff --git a/none/tests/x86/jcxz.stderr.exp b/none/tests/x86/jcxz.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/x86/jcxz.stdout.exp b/none/tests/x86/jcxz.stdout.exp
new file mode 100644 (file)
index 0000000..a11aa31
--- /dev/null
@@ -0,0 +1,2 @@
+test_jcxz(0x1028374)  = 0x8374
+test_jecxz(0x1028374) = 0x1028374
diff --git a/none/tests/x86/jcxz.vgtest b/none/tests/x86/jcxz.vgtest
new file mode 100644 (file)
index 0000000..f034e0d
--- /dev/null
@@ -0,0 +1,2 @@
+prog: jcxz
+vgopts: -q