]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Test x86 {push,pop}{w,l}.
authorJulian Seward <jseward@acm.org>
Fri, 12 May 2006 14:24:18 +0000 (14:24 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 12 May 2006 14:24:18 +0000 (14:24 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5891

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

index 9564b005c94861a9529fa4474a90f5abc5fc3ece..70fe921e8a59ee978ad114a9c2391ee90be111ba 100644 (file)
@@ -10,6 +10,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        $(addsuffix .stdout.exp,$(INSN_TESTS)) \
        $(addsuffix .vgtest,$(INSN_TESTS)) \
        pushfpopf.stderr.exp pushfpopf.stdout.exp pushfpopf.vgtest \
+       pushpopmem.stderr.exp pushpopmem.stdout.exp pushpopmem.vgtest \
        scalar.stderr.exp scalar.stderr.exp2 scalar.vgtest \
        scalar_fork.stderr.exp scalar_fork.vgtest \
        scalar_exit_group.stderr.exp scalar_exit_group.stderr.exp2 \
@@ -25,7 +26,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
 
 check_PROGRAMS = \
        scalar_exit_group scalar_fork scalar_supp scalar_vfork \
-       fpeflags pushfpopf scalar sse_memory tronical \
+       fpeflags pushfpopf pushpopmem scalar sse_memory tronical \
        more_x86_fp fprem
 
 AM_CPPFLAGS  = -I$(top_srcdir)/include
diff --git a/memcheck/tests/x86/pushpopmem.c b/memcheck/tests/x86/pushpopmem.c
new file mode 100644 (file)
index 0000000..fb12233
--- /dev/null
@@ -0,0 +1,62 @@
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+unsigned int do32 ( unsigned int x )
+{
+  unsigned int* y = malloc(sizeof(unsigned int));
+  unsigned int* z = malloc(sizeof(unsigned int));
+  unsigned int t;
+  assert(y);
+  assert(z);
+  y[0] = x;
+  __asm__ __volatile__(
+     "pushl %0\n\t"
+     "pushl %1\n\t"
+     "popl %%ebx\n\t"
+     "popl %%eax\n\t"
+     "pushl 0(%%eax)\n\t"
+     "popl 0(%%ebx)"
+     : /*OUT*/
+     : /*IN*/ "r"(y), "r"(z)
+     : /*TRASH*/ "memory", "eax", "ebx"
+  );
+  t = z[0];
+  free(y);
+  free(z);
+  return t;
+}
+
+unsigned short do16 ( unsigned short x )
+{
+  unsigned short* y = malloc(sizeof(unsigned short));
+  unsigned short* z = malloc(sizeof(unsigned short));
+  unsigned short t;
+  assert(y);
+  assert(z);
+  y[0] = x;
+  __asm__ __volatile__(
+     "pushl %0\n\t"
+     "pushl %1\n\t"
+     "popl %%ebx\n\t"
+     "popl %%eax\n\t"
+     "pushw 0(%%eax)\n\t"
+     "popw 0(%%ebx)"
+     : /*OUT*/
+     : /*IN*/ "r"(y), "r"(z)
+     : /*TRASH*/ "memory", "eax", "ebx"
+  );
+  t = z[0];
+  free(y);
+  free(z);
+  return t;
+}
+
+
+int main ( void )
+{
+   printf("do32: 0x%08X\n", do32(0xCafeBabe) );
+   printf("do16: 0x%08X\n", (unsigned int)do16(0xfeBa) );
+   return 0;
+}
diff --git a/memcheck/tests/x86/pushpopmem.stderr.exp b/memcheck/tests/x86/pushpopmem.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/memcheck/tests/x86/pushpopmem.stdout.exp b/memcheck/tests/x86/pushpopmem.stdout.exp
new file mode 100644 (file)
index 0000000..1dc9138
--- /dev/null
@@ -0,0 +1,2 @@
+do32: 0xCAFEBABE
+do16: 0x0000FEBA
diff --git a/memcheck/tests/x86/pushpopmem.vgtest b/memcheck/tests/x86/pushpopmem.vgtest
new file mode 100644 (file)
index 0000000..142748e
--- /dev/null
@@ -0,0 +1,2 @@
+prog: pushpopmem
+vgopts: -q