drd/tests/swapcontext: Improve the portability of this test further
[valgrind.git] / none / tests / x86 / movx.c
blobfc60cfc0e5a7a8f01fb4ca48abed7fa7ce10d5f2
2 #include <stdio.h>
4 static int movzbw_1 ( void )
6 int res;
7 __asm__ __volatile__(
8 "movl $0x12345678, %%eax\n\t"
9 "movb $0x22, %%al\n\t"
10 "movzbw %%al,%%ax\n\t"
11 "mov %%eax, %0"
12 : "=r"(res) : : "eax"
14 return res;
17 static int movzbw_2 ( void )
19 int res;
20 __asm__ __volatile__(
21 "movl $0x12345678, %%eax\n\t"
22 "movb $0x99, %%al\n\t"
23 "movzbw %%al,%%ax\n\t"
24 "mov %%eax, %0"
25 : "=r"(res) : : "eax"
27 return res;
30 static int movzbl_1 ( void )
32 int res;
33 __asm__ __volatile__(
34 "movl $0x12345678, %%eax\n\t"
35 "movb $0x22, %%al\n\t"
36 "movzbl %%al,%%eax\n\t"
37 "mov %%eax, %0"
38 : "=r"(res) : : "eax"
40 return res;
43 static int movzbl_2 ( void )
45 int res;
46 __asm__ __volatile__(
47 "movl $0x12345678, %%eax\n\t"
48 "movb $0x99, %%al\n\t"
49 "movzbl %%al,%%eax\n\t"
50 "mov %%eax, %0"
51 : "=r"(res) : : "eax"
53 return res;
56 static int movzwl_1 ( void )
58 int res;
59 __asm__ __volatile__(
60 "movl $0x12345678, %%eax\n\t"
61 "movw $0x2222, %%ax\n\t"
62 "movzwl %%ax,%%eax\n\t"
63 "mov %%eax, %0"
64 : "=r"(res) : : "eax"
66 return res;
69 static int movzwl_2 ( void )
71 int res;
72 __asm__ __volatile__(
73 "movl $0x12345678, %%eax\n\t"
74 "movw $0x9999, %%ax\n\t"
75 "movzwl %%ax,%%eax\n\t"
76 "mov %%eax, %0"
77 : "=r"(res) : : "eax"
79 return res;
82 static int movsbw_1 ( void )
84 int res;
85 __asm__ __volatile__(
86 "movl $0x12345678, %%eax\n\t"
87 "movb $0x22, %%al\n\t"
88 "movsbw %%al,%%ax\n\t"
89 "mov %%eax, %0"
90 : "=r"(res) : : "eax"
92 return res;
95 static int movsbw_2 ( void )
97 int res;
98 __asm__ __volatile__(
99 "movl $0x12345678, %%eax\n\t"
100 "movb $0x99, %%al\n\t"
101 "movsbw %%al,%%ax\n\t"
102 "mov %%eax, %0"
103 : "=r"(res) : : "eax"
105 return res;
108 static int movsbl_1 ( void )
110 int res;
111 __asm__ __volatile__(
112 "movl $0x12345678, %%eax\n\t"
113 "movb $0x22, %%al\n\t"
114 "movsbl %%al,%%eax\n\t"
115 "mov %%eax, %0"
116 : "=r"(res) : : "eax"
118 return res;
121 static int movsbl_2 ( void )
123 int res;
124 __asm__ __volatile__(
125 "movl $0x12345678, %%eax\n\t"
126 "movb $0x99, %%al\n\t"
127 "movsbl %%al,%%eax\n\t"
128 "mov %%eax, %0"
129 : "=r"(res) : : "eax"
131 return res;
134 static int movswl_1 ( void )
136 int res;
137 __asm__ __volatile__(
138 "movl $0x12345678, %%eax\n\t"
139 "movw $0x2222, %%ax\n\t"
140 "movswl %%ax,%%eax\n\t"
141 "mov %%eax, %0"
142 : "=r"(res) : : "eax"
144 return res;
147 static int movswl_2 ( void )
149 int res;
150 __asm__ __volatile__(
151 "movl $0x12345678, %%eax\n\t"
152 "movw $0x9999, %%ax\n\t"
153 "movswl %%ax,%%eax\n\t"
154 "mov %%eax, %0"
155 : "=r"(res) : : "eax"
157 return res;
162 int main ( void )
164 printf("%8s 0x%08x\n", "movzbw_1", movzbw_1());
165 printf("%8s 0x%08x\n", "movzbw_2", movzbw_2());
166 printf("%8s 0x%08x\n", "movzbl_1", movzbl_1());
167 printf("%8s 0x%08x\n", "movzbl_2", movzbl_2());
168 printf("%8s 0x%08x\n", "movzwl_1", movzwl_1());
169 printf("%8s 0x%08x\n", "movzwl_2", movzwl_2());
170 printf("%8s 0x%08x\n", "movsbw_1", movsbw_1());
171 printf("%8s 0x%08x\n", "movsbw_2", movsbw_2());
172 printf("%8s 0x%08x\n", "movsbl_1", movsbl_1());
173 printf("%8s 0x%08x\n", "movsbl_2", movsbl_2());
174 printf("%8s 0x%08x\n", "movswl_1", movswl_1());
175 printf("%8s 0x%08x\n", "movswl_2", movswl_2());
176 return 0;