regtest: broaden none/tests/linux/bug498317 suppression for PPC
[valgrind.git] / none / tests / amd64 / sbbmisc.c
blob82b5db0ce2710dcb434c4ae8c566f52ae7126839
1 #include "tests/asm.h"
2 #include <stdio.h>
4 char in_b, out_b1, out_b2, in_b2;
6 short in_w, out_w1, out_w2;
8 int in_l, out_l1, out_l2;
10 extern void sbb_ib_al ( void );
11 asm("\n"
12 ".text\n"
13 VG_SYM(sbb_ib_al) ":\n"
15 #ifndef VGP_amd64_darwin
16 "\tmovb " VG_SYM(in_b) ", %al\n"
17 #else
18 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
19 #endif
21 "\tclc\n"
22 "\tsbbb $5, %al\n"
23 #ifndef VGP_amd64_darwin
24 "\tmovb %al, " VG_SYM(out_b1) "\n"
26 "\tmovb " VG_SYM(in_b) ", %al\n"
27 #else
28 "\tmovb %al, " VG_SYM(out_b1) "(%rip)\n"
30 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
31 #endif
32 "\tstc\n"
33 "\tsbbb $5, %al\n"
34 #ifndef VGP_amd64_darwin
35 "\tmovb %al, " VG_SYM(out_b2) "\n"
36 #else
37 "\tmovb %al," VG_SYM(out_b2) "(%rip) \n"
38 #endif
40 "\tretq\n"
41 ".previous\n"
45 extern void sbb_iw_ax ( void );
46 asm("\n"
47 ".text\n"
48 VG_SYM(sbb_iw_ax) ":\n"
50 #ifndef VGP_amd64_darwin
51 "\tmovw " VG_SYM(in_w) ", %ax\n"
52 #else
53 "\tmovw " VG_SYM(in_w) "(%rip), %ax\n"
54 #endif
55 "\tclc\n"
56 "\tsbbw $555, %ax\n"
57 #ifndef VGP_amd64_darwin
58 "\tmovw %ax, " VG_SYM(out_w1) "\n"
60 "\tmovw " VG_SYM(in_w) ", %ax\n"
61 #else
62 "\tmovw %ax, " VG_SYM(out_w1) "(%rip)\n"
64 "\tmovw " VG_SYM(in_w) "(%rip), %ax\n"
65 #endif
66 "\tstc\n"
67 "\tsbbw $555, %ax\n"
68 #ifndef VGP_amd64_darwin
69 "\tmovw %ax, " VG_SYM(out_w2) "\n"
70 #else
71 "\tmovw %ax, " VG_SYM(out_w2) "(%rip)\n"
72 #endif
74 "\tretq\n"
75 ".previous\n"
79 extern void sbb_il_eax ( void );
80 asm("\n"
81 ".text\n"
82 VG_SYM(sbb_il_eax) ":\n"
84 #ifndef VGP_amd64_darwin
85 "\tmovl " VG_SYM(in_l) ", %eax\n"
86 #else
87 "\tmovl " VG_SYM(in_l) "(%rip), %eax\n"
88 #endif
89 "\tclc\n"
90 "\tsbbl $555666, %eax\n"
91 #ifndef VGP_amd64_darwin
92 "\tmovl %eax, " VG_SYM(out_l1) "\n"
94 "\tmovl " VG_SYM(in_l) ", %eax\n"
95 #else
96 "\tmovl %eax, " VG_SYM(out_l1) "(%rip)\n"
98 "\tmovl " VG_SYM(in_l) "(%rip), %eax\n"
99 #endif
100 "\tstc\n"
101 "\tsbbl $555666, %eax\n"
102 #ifndef VGP_amd64_darwin
103 "\tmovl %eax, " VG_SYM(out_l2) "\n"
104 #else
105 "\tmovl %eax, " VG_SYM(out_l2) "(%rip)\n"
106 #endif
108 "\tretq\n"
109 ".previous\n"
113 extern void sbb_eb_gb ( void );
114 asm("\n"
115 ".text\n"
116 VG_SYM(sbb_eb_gb) ":\n"
118 #ifndef VGP_amd64_darwin
119 "\tmovb " VG_SYM(in_b) ", %al\n"
120 #else
121 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
122 #endif
123 "\tclc\n"
124 #ifndef VGP_amd64_darwin
125 "\tsbbb " VG_SYM(in_b2) ", %al\n"
126 "\tmovb %al, " VG_SYM(out_b1) "\n"
128 "\tmovb " VG_SYM(in_b) ", %al\n"
129 #else
130 "\tsbbb " VG_SYM(in_b2) "(%rip), %al\n"
131 "\tmovb %al, " VG_SYM(out_b1) "(%rip)\n"
133 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
134 #endif
135 "\tstc\n"
136 #ifndef VGP_amd64_darwin
137 "\tsbbb " VG_SYM(in_b2) ", %al\n"
138 "\tmovb %al, " VG_SYM(out_b2) "\n"
139 #else
140 "\tsbbb " VG_SYM(in_b2) "(%rip), %al\n"
141 "\tmovb %al, " VG_SYM(out_b2) "(%rip)\n"
142 #endif
144 "\tretq\n"
145 ".previous\n"
149 extern void sbb_eb_gb_2 ( void );
150 asm("\n"
151 ".text\n"
152 VG_SYM(sbb_eb_gb_2) ":\n"
153 "\tpushq %rcx\n"
155 #ifndef VGP_amd64_darwin
156 "\tmovb " VG_SYM(in_b) ", %cl\n"
157 "\tmovb " VG_SYM(in_b2) ", %dh\n"
158 #else
159 "\tmovb " VG_SYM(in_b) "(%rip), %cl\n"
160 "\tmovb " VG_SYM(in_b2) "(%rip), %dh\n"
161 #endif
162 "\tclc\n"
163 "\tsbbb %dh,%cl\n"
164 #ifndef VGP_amd64_darwin
165 "\tmovb %cl, " VG_SYM(out_b1) "\n"
167 "\tmovb " VG_SYM(in_b) ", %cl\n"
168 "\tmovb " VG_SYM(in_b2) ", %dh\n"
169 #else
170 "\tmovb %cl, " VG_SYM(out_b1) "(%rip)\n"
172 "\tmovb " VG_SYM(in_b) "(%rip), %cl\n"
173 "\tmovb " VG_SYM(in_b2) "(%rip), %dh\n"
174 #endif
175 "\tstc\n"
176 "\tsbbb %dh,%cl\n"
177 #ifndef VGP_amd64_darwin
178 "\tmovb %cl, " VG_SYM(out_b2) "\n"
179 #else
180 "\tmovb %cl, " VG_SYM(out_b2) "(%rip)\n"
181 #endif
183 "\tpopq %rcx\n"
184 "\tretq\n"
185 ".previous\n"
189 extern void adc_eb_gb ( void );
190 asm("\n"
191 ".text\n"
192 VG_SYM(adc_eb_gb) ":\n"
194 #ifndef VGP_amd64_darwin
195 "\tmovb " VG_SYM(in_b) ", %al\n"
196 #else
197 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
198 #endif
199 "\tclc\n"
200 #ifndef VGP_amd64_darwin
201 "\tadcb " VG_SYM(in_b2) ", %al\n"
202 "\tmovb %al, " VG_SYM(out_b1) "\n"
204 "\tmovb " VG_SYM(in_b) ", %al\n"
205 #else
206 "\tadcb " VG_SYM(in_b2) "(%rip), %al\n"
207 "\tmovb %al, " VG_SYM(out_b1) "(%rip)\n"
209 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
210 #endif
211 "\tstc\n"
212 #ifndef VGP_amd64_darwin
213 "\tadcb " VG_SYM(in_b2) ", %al\n"
214 "\tmovb %al, " VG_SYM(out_b2) "\n"
215 #else
216 "\tadcb " VG_SYM(in_b2) "(%rip), %al\n"
217 "\tmovb %al, " VG_SYM(out_b2) "(%rip)\n"
218 #endif
220 "\tretq\n"
221 ".previous\n"
225 extern void adc_eb_gb_2 ( void );
226 asm("\n"
227 ".text\n"
228 VG_SYM(adc_eb_gb_2) ":\n"
229 "\tpushq %rcx\n"
231 #ifndef VGP_amd64_darwin
232 "\tmovb " VG_SYM(in_b) ", %cl\n"
233 "\tmovb " VG_SYM(in_b2) ", %dh\n"
234 #else
235 "\tmovb " VG_SYM(in_b) "(%rip), %cl\n"
236 "\tmovb " VG_SYM(in_b2) "(%rip), %dh\n"
237 #endif
238 "\tclc\n"
239 "\tadcb %dh,%cl\n"
240 #ifndef VGP_amd64_darwin
241 "\tmovb %cl, " VG_SYM(out_b1) "\n"
243 "\tmovb " VG_SYM(in_b) ", %cl\n"
244 "\tmovb " VG_SYM(in_b2) ", %dh\n"
245 #else
246 "\tmovb %cl, " VG_SYM(out_b1) "(%rip)\n"
248 "\tmovb " VG_SYM(in_b) "(%rip), %cl\n"
249 "\tmovb " VG_SYM(in_b2) "(%rip), %dh\n"
250 #endif
251 "\tstc\n"
252 "\tadcb %dh,%cl\n"
253 #ifndef VGP_amd64_darwin
254 "\tmovb %cl, " VG_SYM(out_b2) "\n"
255 #else
256 "\tmovb %cl, " VG_SYM(out_b2) "(%rip)\n"
257 #endif
259 "\tpopq %rcx\n"
260 "\tretq\n"
261 ".previous\n"
264 extern void adc_ib_al ( void );
265 asm("\n"
266 ".text\n"
267 VG_SYM(adc_ib_al) ":\n"
269 #ifndef VGP_amd64_darwin
270 "\tmovb " VG_SYM(in_b) ", %al\n"
271 #else
272 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
273 #endif
274 "\tclc\n"
275 "\tadcb $5, %al\n"
276 #ifndef VGP_amd64_darwin
277 "\tmovb %al, " VG_SYM(out_b1) "\n"
279 "\tmovb " VG_SYM(in_b) ", %al\n"
280 #else
281 "\tmovb %al, " VG_SYM(out_b1) "(%rip)\n"
283 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
284 #endif
285 "\tstc\n"
286 "\tadcb $5, %al\n"
287 #ifndef VGP_amd64_darwin
288 "\tmovb %al, " VG_SYM(out_b2) "\n"
289 #else
290 "\tmovb %al, " VG_SYM(out_b2) "(%rip)\n"
291 #endif
293 "\tretq\n"
294 ".previous\n"
298 extern void adc_iw_ax ( void );
299 asm("\n"
300 ".text\n"
301 VG_SYM(adc_iw_ax) ":\n"
303 #ifndef VGP_amd64_darwin
304 "\tmovw " VG_SYM(in_w) ", %ax\n"
305 #else
306 "\tmovw " VG_SYM(in_w) "(%rip), %ax\n"
307 #endif
308 "\tclc\n"
309 "\tadcw $555, %ax\n"
310 #ifndef VGP_amd64_darwin
311 "\tmovw %ax, " VG_SYM(out_w1) "\n"
313 "\tmovw " VG_SYM(in_w) ", %ax\n"
314 #else
315 "\tmovw %ax, " VG_SYM(out_w1) "(%rip)\n"
317 "\tmovw " VG_SYM(in_w) "(%rip), %ax\n"
318 #endif
319 "\tstc\n"
320 "\tadcw $555, %ax\n"
321 #ifndef VGP_amd64_darwin
322 "\tmovw %ax, " VG_SYM(out_w2) "\n"
323 #else
324 "\tmovw %ax, " VG_SYM(out_w2) "(%rip)\n"
325 #endif
327 "\tretq\n"
328 ".previous\n"
332 extern void adc_il_eax ( void );
333 asm("\n"
334 ".text\n"
335 VG_SYM(adc_il_eax) ":\n"
337 #ifndef VGP_amd64_darwin
338 "\tmovl " VG_SYM(in_l) ", %eax\n"
339 #else
340 "\tmovl " VG_SYM(in_l) "(%rip), %eax\n"
341 #endif
342 "\tclc\n"
343 "\tadcl $555666, %eax\n"
344 #ifndef VGP_amd64_darwin
345 "\tmovl %eax, " VG_SYM(out_l1) "\n"
347 "\tmovl " VG_SYM(in_l) ", %eax\n"
348 #else
349 "\tmovl %eax, " VG_SYM(out_l1) "(%rip)\n"
351 "\tmovl " VG_SYM(in_l) "(%rip), %eax\n"
352 #endif
353 "\tstc\n"
354 "\tadcl $555666, %eax\n"
355 #ifndef VGP_amd64_darwin
356 "\tmovl %eax, " VG_SYM(out_l2) "\n"
357 #else
358 "\tmovl %eax, " VG_SYM(out_l2) "(%rip)\n"
359 #endif
361 "\tretq\n"
362 ".previous\n"
366 int main ( void )
368 in_b = 99;
369 sbb_ib_al();
370 printf("r1 = %d %d\n", (int)out_b1, (int)out_b2);
372 in_w = -15537; /* was 49999 but that causes a warning */
373 sbb_iw_ax();
374 printf("r2 = %d %d\n", (int)out_w1, (int)out_w2);
376 in_l = 0xF0000000;
377 sbb_il_eax();
378 printf("r3 = %d %d\n", (int)out_l1, (int)out_l2);
380 in_b = 99;
381 in_b2 = 88;
382 sbb_eb_gb();
383 printf("r4 = %d %d\n", (int)out_b1, (int)out_b2);
385 in_b = 66;
386 in_b2 = 77;
387 sbb_eb_gb_2();
388 printf("r5 = %d %d\n", (int)out_b1, (int)out_b2);
390 in_b = 99;
391 in_b2 = 88;
392 adc_eb_gb();
393 printf("r6 = %d %d\n", (int)out_b1, (int)out_b2);
395 in_b = 66;
396 in_b2 = 77;
397 adc_eb_gb_2();
398 printf("r7 = %d %d\n", (int)out_b1, (int)out_b2);
400 in_b = 99;
401 adc_ib_al();
402 printf("r8 = %d %d\n", (int)out_b1, (int)out_b2);
404 in_w = -15537;
405 adc_iw_ax();
406 printf("r9 = %d %d\n", (int)out_w1, (int)out_w2);
408 in_l = 0xF0000000;
409 adc_il_eax();
410 printf("r10 = %d %d\n", (int)out_l1, (int)out_l2);
412 return 0;