Implement VMOVQ xmm1, xmm2/m64
[valgrind.git] / VEX / test / frstor.c
blob006e19ee3cfe278b7a1733e74332b69d4fd3bc06
2 #include <stdio.h>
3 #include <stdlib.h>
5 void do_fsave_interesting_stuff ( void* p )
7 asm __volatile__("fninit");
8 asm __volatile__("fldpi");
9 asm __volatile__("fld1");
10 asm __volatile__("fldln2");
11 asm __volatile__("fsave (%0)" : : "r" (p) : "memory" );
14 void do_fsave ( void* p )
16 asm __volatile__("fsave (%0)" : : "r" (p) : "memory" );
19 void do_frstor ( void* p )
21 asm __volatile__("frstor (%0)" : : "r" (p) : "memory" );
25 int isFPLsbs ( int i )
27 int q;
28 q = 0; if (i == q || i == q+1) return 1;
29 q = 10; if (i == q || i == q+1) return 1;
30 q = 20; if (i == q || i == q+1) return 1;
31 q = 30; if (i == q || i == q+1) return 1;
32 q = 40; if (i == q || i == q+1) return 1;
33 q = 50; if (i == q || i == q+1) return 1;
34 q = 60; if (i == q || i == q+1) return 1;
35 q = 70; if (i == q || i == q+1) return 1;
36 return 0;
39 void show_fpustate ( unsigned char* buf, int hide64to80 )
41 int i;
42 printf(" 0 ");
43 for (i = 0; i < 14; i++)
44 printf("%02x ", buf[i]);
45 printf("\n");
47 printf(" 14 ");
48 for (i = 14; i < 28; i++)
49 printf("%02x ", buf[i]);
50 printf("\n");
52 for (i = 0; i < 80; i++) {
53 if ((i % 10) == 0)
54 printf("%3d ", i+28);
55 if (hide64to80 && isFPLsbs(i))
56 printf("xx ");
57 else
58 printf("%02x ", buf[i+28]);
59 if (i > 0 && ((i % 10) == 9))
60 printf("\n");
64 int main ( int argc, char** argv )
66 unsigned short* buf1 = malloc(54*sizeof(short));
67 unsigned short* buf2 = malloc(54*sizeof(short));
68 int xx = argc > 1;
69 printf("Re-run with any arg to suppress least-significant\n"
70 " 16 bits of FP numbers\n");
72 /* Create an initial image. */
73 do_fsave_interesting_stuff(buf1);
74 show_fpustate( (unsigned char*)buf1, xx );
76 /* Reload it into buf2. */
77 do_frstor(buf1);
78 do_fsave(buf2);
79 show_fpustate( (unsigned char*)buf2, xx );
81 return 0;