Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / x86 / pushpopmem.c
blobfb122339d98117ef6163eb14bca0d43b4015f3f8
2 #include <assert.h>
3 #include <stdio.h>
4 #include <stdlib.h>
6 unsigned int do32 ( unsigned int x )
8 unsigned int* y = malloc(sizeof(unsigned int));
9 unsigned int* z = malloc(sizeof(unsigned int));
10 unsigned int t;
11 assert(y);
12 assert(z);
13 y[0] = x;
14 __asm__ __volatile__(
15 "pushl %0\n\t"
16 "pushl %1\n\t"
17 "popl %%ebx\n\t"
18 "popl %%eax\n\t"
19 "pushl 0(%%eax)\n\t"
20 "popl 0(%%ebx)"
21 : /*OUT*/
22 : /*IN*/ "r"(y), "r"(z)
23 : /*TRASH*/ "memory", "eax", "ebx"
25 t = z[0];
26 free(y);
27 free(z);
28 return t;
31 unsigned short do16 ( unsigned short x )
33 unsigned short* y = malloc(sizeof(unsigned short));
34 unsigned short* z = malloc(sizeof(unsigned short));
35 unsigned short t;
36 assert(y);
37 assert(z);
38 y[0] = x;
39 __asm__ __volatile__(
40 "pushl %0\n\t"
41 "pushl %1\n\t"
42 "popl %%ebx\n\t"
43 "popl %%eax\n\t"
44 "pushw 0(%%eax)\n\t"
45 "popw 0(%%ebx)"
46 : /*OUT*/
47 : /*IN*/ "r"(y), "r"(z)
48 : /*TRASH*/ "memory", "eax", "ebx"
50 t = z[0];
51 free(y);
52 free(z);
53 return t;
57 int main ( void )
59 printf("do32: 0x%08X\n", do32(0xCafeBabe) );
60 printf("do16: 0x%08X\n", (unsigned int)do16(0xfeBa) );
61 return 0;