4 /* This test only checks register/register cmpxchg */
6 typedef unsigned long long int ULong
;
7 typedef unsigned int UInt
;
24 rdx
= 0x11111111; rax
= 0x22222222;
25 rcx
= 0x33333333; rbx
= 0x44444444;
27 printf("cmpxchg %%bl,%%cl (al=%llx bl=%llx cl=%llx)\n",
28 rax
&0xff,rbx
&0xff,rcx
&0xff);
35 "\txor %rax, %rax\n" // get eflags in a known state
36 #ifndef VGP_amd64_darwin
37 "\tmov " VG_SYM(rax
) ",%rax\n"
38 "\tmov " VG_SYM(rbx
) ",%rbx\n"
39 "\tmov " VG_SYM(rcx
) ",%rcx\n"
40 "\tmov " VG_SYM(rdx
) ",%rdx\n"
42 "\tmov " VG_SYM(rax
) "(%rip),%rax\n"
43 "\tmov " VG_SYM(rbx
) "(%rip),%rbx\n"
44 "\tmov " VG_SYM(rcx
) "(%rip),%rcx\n"
45 "\tmov " VG_SYM(rdx
) "(%rip),%rdx\n"
47 "\tcmpxchg %bl,%cl \n"
48 #ifndef VGP_amd64_darwin
49 "\tmov %rax," VG_SYM(rax_out
) "\n"
50 "\tmov %rbx," VG_SYM(rbx_out
) "\n"
51 "\tmov %rcx," VG_SYM(rcx_out
) "\n"
53 "\tmov %rax," VG_SYM(rax_out
) "(%rip)\n"
54 "\tmov %rbx," VG_SYM(rbx_out
) "(%rip)\n"
55 "\tmov %rcx," VG_SYM(rcx_out
) "(%rip)\n"
63 printf(" al!=cl so al should equal cl (Result al=%llx bl=%llx cl=%llx)\n",
64 rax_out
&0xff,rbx_out
&0xff,rcx_out
&0xff);
68 rdx
= 0x99999999; rax
= 0x77777777;
69 rcx
= 0x55555555; rbx
= 0x55555555;
71 printf("cmpxchg %%bl,%%cl (al=%llx bl=%llx cl=%llx)\n",
72 rax
&0xff,rbx
&0xff,rcx
&0xff);
79 "\txor %rax, %rax\n" // get eflags in a known state
80 #ifndef VGP_amd64_darwin
81 "\tmov " VG_SYM(rax
) ",%rax\n"
82 "\tmov " VG_SYM(rbx
) ",%rbx\n"
83 "\tmov " VG_SYM(rcx
) ",%rcx\n"
84 "\tmov " VG_SYM(rdx
) ",%rdx\n"
86 "\tmov " VG_SYM(rax
) "(%rip),%rax\n"
87 "\tmov " VG_SYM(rbx
) "(%rip),%rbx\n"
88 "\tmov " VG_SYM(rcx
) "(%rip),%rcx\n"
89 "\tmov " VG_SYM(rdx
) "(%rip),%rdx\n"
91 "\tcmpxchg %bl,%cl \n"
92 #ifndef VGP_amd64_darwin
93 "\tmov %rax," VG_SYM(rax_out
) "\n"
94 "\tmov %rbx," VG_SYM(rbx_out
) "\n"
95 "\tmov %rcx," VG_SYM(rcx_out
) "\n"
97 "\tmov %rax," VG_SYM(rax_out
) "(%rip)\n"
98 "\tmov %rbx," VG_SYM(rbx_out
) "(%rip)\n"
99 "\tmov %rcx," VG_SYM(rcx_out
) "(%rip)\n"
107 printf(" al==cl so cl should equal bl (Result al=%llx bl=%llx cl=%llx)\n",
108 rax_out
&0xff,rbx_out
&0xff,rcx_out
&0xff);
112 rdx
= 0x11111111; rax
= 0x22222222;
113 rcx
= 0x33333333; rbx
= 0x44444444;
115 printf("cmpxchg %%bx,%%cx (ax=%llx bx=%llx cx=%llx)\n",
116 rax
&0xffff,rbx
&0xffff,rcx
&0xffff);
123 "\txor %rax, %rax\n" // get eflags in a known state
124 #ifndef VGP_amd64_darwin
125 "\tmov " VG_SYM(rax
) ",%rax\n"
126 "\tmov " VG_SYM(rbx
) ",%rbx\n"
127 "\tmov " VG_SYM(rcx
) ",%rcx\n"
128 "\tmov " VG_SYM(rdx
) ",%rdx\n"
130 "\tmov " VG_SYM(rax
) "(%rip),%rax\n"
131 "\tmov " VG_SYM(rbx
) "(%rip),%rbx\n"
132 "\tmov " VG_SYM(rcx
) "(%rip),%rcx\n"
133 "\tmov " VG_SYM(rdx
) "(%rip),%rdx\n"
135 "\tcmpxchg %bx,%cx \n"
136 #ifndef VGP_amd64_darwin
137 "\tmov %rax," VG_SYM(rax_out
) "\n"
138 "\tmov %rbx," VG_SYM(rbx_out
) "\n"
139 "\tmov %rcx," VG_SYM(rcx_out
) "\n"
141 "\tmov %rax," VG_SYM(rax_out
) "(%rip)\n"
142 "\tmov %rbx," VG_SYM(rbx_out
) "(%rip)\n"
143 "\tmov %rcx," VG_SYM(rcx_out
) "(%rip)\n"
151 printf(" ax!=cx so ax should equal cx (Result ax=%llx bx=%llx cx=%llx)\n",
152 rax_out
&0xffff,rbx_out
&0xffff,rcx_out
&0xffff);
156 rdx
= 0x99999999; rax
= 0x77777777;
157 rcx
= 0x55555555; rbx
= 0x55555555;
159 printf("cmpxchg %%bx,%%cx (ax=%llx bx=%llx cx=%llx)\n",
160 rax
&0xffff,rbx
&0xffff,rcx
&0xffff);
167 "\txor %rax, %rax\n" // get eflags in a known state
168 #ifndef VGP_amd64_darwin
169 "\tmov " VG_SYM(rax
) ",%rax\n"
170 "\tmov " VG_SYM(rbx
) ",%rbx\n"
171 "\tmov " VG_SYM(rcx
) ",%rcx\n"
172 "\tmov " VG_SYM(rdx
) ",%rdx\n"
174 "\tmov " VG_SYM(rax
) "(%rip),%rax\n"
175 "\tmov " VG_SYM(rbx
) "(%rip),%rbx\n"
176 "\tmov " VG_SYM(rcx
) "(%rip),%rcx\n"
177 "\tmov " VG_SYM(rdx
) "(%rip),%rdx\n"
179 "\tcmpxchg %bx,%cx \n"
180 #ifndef VGP_amd64_darwin
181 "\tmov %rax," VG_SYM(rax_out
) "\n"
182 "\tmov %rbx," VG_SYM(rbx_out
) "\n"
183 "\tmov %rcx," VG_SYM(rcx_out
) "\n"
185 "\tmov %rax," VG_SYM(rax_out
) "(%rip)\n"
186 "\tmov %rbx," VG_SYM(rbx_out
) "(%rip)\n"
187 "\tmov %rcx," VG_SYM(rcx_out
) "(%rip)\n"
195 printf(" ax==cx so cx should equal bx (Result ax=%llx bx=%llx cx=%llx)\n",
196 rax_out
&0xffff,rbx_out
&0xffff,rcx_out
&0xffff);
201 rdx
= 0x11111111; rax
= 0x22222222;
202 rcx
= 0x33333333; rbx
= 0x44444444;
204 printf("cmpxchg %%ebx,%%ecx (eax=%llx ebx=%llx ecx=%llx)\n",
205 rax
&0xffffffff,rbx
&0xffffffff,rcx
&0xffffffff);
212 "\txor %rax, %rax\n" // get eflags in a known state
213 #ifndef VGP_amd64_darwin
214 "\tmov " VG_SYM(rax
) ",%rax\n"
215 "\tmov " VG_SYM(rbx
) ",%rbx\n"
216 "\tmov " VG_SYM(rcx
) ",%rcx\n"
217 "\tmov " VG_SYM(rdx
) ",%rdx\n"
219 "\tmov " VG_SYM(rax
) "(%rip),%rax\n"
220 "\tmov " VG_SYM(rbx
) "(%rip),%rbx\n"
221 "\tmov " VG_SYM(rcx
) "(%rip),%rcx\n"
222 "\tmov " VG_SYM(rdx
) "(%rip),%rdx\n"
224 "\tcmpxchg %ebx,%ecx \n"
225 #ifndef VGP_amd64_darwin
226 "\tmov %rax," VG_SYM(rax_out
) "\n"
227 "\tmov %rbx," VG_SYM(rbx_out
) "\n"
228 "\tmov %rcx," VG_SYM(rcx_out
) "\n"
230 "\tmov %rax," VG_SYM(rax_out
) "(%rip)\n"
231 "\tmov %rbx," VG_SYM(rbx_out
) "(%rip)\n"
232 "\tmov %rcx," VG_SYM(rcx_out
) "(%rip)\n"
240 printf(" eax!=ecx so eax should equal ecx (Result eax=%llx ebx=%llx ecx=%llx)\n",
241 rax_out
&0xffffffff,rbx_out
&0xffffffff,rcx_out
&0xffffffff);
245 rdx
= 0x99999999; rax
= 0x77777777;
246 rcx
= 0x55555555; rbx
= 0x55555555;
248 printf("cmpxchg %%ebx,%%ecx (eax=%llx ebx=%llx ecx=%llx)\n",
249 rax
&0xffffffff,rbx
&0xffffffff,rcx
&0xffffffff);
256 "\txor %rax, %rax\n" // get eflags in a known state
257 #ifndef VGP_amd64_darwin
258 "\tmov " VG_SYM(rax
) ",%rax\n"
259 "\tmov " VG_SYM(rbx
) ",%rbx\n"
260 "\tmov " VG_SYM(rcx
) ",%rcx\n"
261 "\tmov " VG_SYM(rdx
) ",%rdx\n"
263 "\tmov " VG_SYM(rax
) "(%rip),%rax\n"
264 "\tmov " VG_SYM(rbx
) "(%rip),%rbx\n"
265 "\tmov " VG_SYM(rcx
) "(%rip),%rcx\n"
266 "\tmov " VG_SYM(rdx
) "(%rip),%rdx\n"
268 "\tcmpxchg %ebx,%ecx \n"
269 #ifndef VGP_amd64_darwin
270 "\tmov %rax," VG_SYM(rax_out
) "\n"
271 "\tmov %rbx," VG_SYM(rbx_out
) "\n"
272 "\tmov %rcx," VG_SYM(rcx_out
) "\n"
274 "\tmov %rax," VG_SYM(rax_out
) "(%rip)\n"
275 "\tmov %rbx," VG_SYM(rbx_out
) "(%rip)\n"
276 "\tmov %rcx," VG_SYM(rcx_out
) "(%rip)\n"
284 printf(" eax==ecx so ecx should equal ebx (Result eax=%llx ebx=%llx ecx=%llx)\n",
285 rax_out
&0xffffffff,rbx_out
&0xffffffff,rcx_out
&0xffffffff);
290 rdx
= 0x111111111; rax
= 0x222222222;
291 rcx
= 0x333333333; rbx
= 0x444444444;
293 printf("cmpxchg %%rbx,%%rcx (rax=%llx rbx=%llx rcx=%llx)\n",
301 "\txor %rax, %rax\n" // get eflags in a known state
302 #ifndef VGP_amd64_darwin
303 "\tmov " VG_SYM(rax
) ",%rax\n"
304 "\tmov " VG_SYM(rbx
) ",%rbx\n"
305 "\tmov " VG_SYM(rcx
) ",%rcx\n"
306 "\tmov " VG_SYM(rdx
) ",%rdx\n"
308 "\tmov " VG_SYM(rax
) "(%rip),%rax\n"
309 "\tmov " VG_SYM(rbx
) "(%rip),%rbx\n"
310 "\tmov " VG_SYM(rcx
) "(%rip),%rcx\n"
311 "\tmov " VG_SYM(rdx
) "(%rip),%rdx\n"
313 "\tcmpxchg %rbx,%rcx \n"
314 #ifndef VGP_amd64_darwin
315 "\tmov %rax," VG_SYM(rax_out
) "\n"
316 "\tmov %rbx," VG_SYM(rbx_out
) "\n"
317 "\tmov %rcx," VG_SYM(rcx_out
) "\n"
319 "\tmov %rax," VG_SYM(rax_out
) "(%rip)\n"
320 "\tmov %rbx," VG_SYM(rbx_out
) "(%rip)\n"
321 "\tmov %rcx," VG_SYM(rcx_out
) "(%rip)\n"
329 printf(" rax!=rcx so rax should equal rcx (Result rax=%llx rbx=%llx rcx=%llx)\n",
330 rax_out
,rbx_out
,rcx_out
);
334 rdx
= 0x999999999; rax
= 0x777777777;
335 rcx
= 0x555555555; rbx
= 0x555555555;
337 printf("cmpxchg %%rbx,%%rcx (rax=%llx rbx=%llx rcx=%llx)\n",
345 "\txor %rax, %rax\n" // get eflags in a known state
346 #ifndef VGP_amd64_darwin
347 "\tmov " VG_SYM(rax
) ",%rax\n"
348 "\tmov " VG_SYM(rbx
) ",%rbx\n"
349 "\tmov " VG_SYM(rcx
) ",%rcx\n"
350 "\tmov " VG_SYM(rdx
) ",%rdx\n"
352 "\tmov " VG_SYM(rax
) "(%rip),%rax\n"
353 "\tmov " VG_SYM(rbx
) "(%rip),%rbx\n"
354 "\tmov " VG_SYM(rcx
) "(%rip),%rcx\n"
355 "\tmov " VG_SYM(rdx
) "(%rip),%rdx\n"
357 "\tcmpxchg %rbx,%rcx \n"
358 #ifndef VGP_amd64_darwin
359 "\tmov %rax," VG_SYM(rax_out
) "\n"
360 "\tmov %rbx," VG_SYM(rbx_out
) "\n"
361 "\tmov %rcx," VG_SYM(rcx_out
) "\n"
363 "\tmov %rax," VG_SYM(rax_out
) "(%rip)\n"
364 "\tmov %rbx," VG_SYM(rbx_out
) "(%rip)\n"
365 "\tmov %rcx," VG_SYM(rcx_out
) "(%rip)\n"
373 printf(" rax==rcx so ecx should equal rbx (Result rax=%llx rbx=%llx rcx=%llx)\n",
374 rax_out
,rbx_out
,rcx_out
);