219 |
|
return 0; |
220 |
|
} |
221 |
|
|
222 |
+ |
/* Manually emit LAHF instruction so that 64-bit assemblers can grok it */ |
223 |
+ |
#if defined __x86_64__ && defined __GNUC__ |
224 |
+ |
#define ASM_LAHF ".byte 0x9f" |
225 |
+ |
#else |
226 |
+ |
#define ASM_LAHF "lahf" |
227 |
+ |
#endif |
228 |
+ |
|
229 |
|
/* Is there any way to do this without declaring *all* memory clobbered? |
230 |
|
I.e. any way to tell gcc that some byte-sized value is in %al? */ |
231 |
|
#define optflag_testl(v) \ |
232 |
|
__asm__ __volatile__ ("andl %0,%0\n\t" \ |
233 |
< |
"lahf\n\t" \ |
233 |
> |
ASM_LAHF "\n\t" \ |
234 |
|
"seto %%al\n\t" \ |
235 |
|
"movb %%al,regflags\n\t" \ |
236 |
|
"movb %%ah,regflags+1\n\t" \ |
238 |
|
|
239 |
|
#define optflag_testw(v) \ |
240 |
|
__asm__ __volatile__ ("andw %w0,%w0\n\t" \ |
241 |
< |
"lahf\n\t" \ |
241 |
> |
ASM_LAHF "\n\t" \ |
242 |
|
"seto %%al\n\t" \ |
243 |
|
"movb %%al,regflags\n\t" \ |
244 |
|
"movb %%ah,regflags+1\n\t" \ |
246 |
|
|
247 |
|
#define optflag_testb(v) \ |
248 |
|
__asm__ __volatile__ ("andb %b0,%b0\n\t" \ |
249 |
< |
"lahf\n\t" \ |
249 |
> |
ASM_LAHF "\n\t" \ |
250 |
|
"seto %%al\n\t" \ |
251 |
|
"movb %%al,regflags\n\t" \ |
252 |
|
"movb %%ah,regflags+1\n\t" \ |
254 |
|
|
255 |
|
#define optflag_addl(v, s, d) do { \ |
256 |
|
__asm__ __volatile__ ("addl %k1,%k0\n\t" \ |
257 |
< |
"lahf\n\t" \ |
257 |
> |
ASM_LAHF "\n\t" \ |
258 |
|
"seto %%al\n\t" \ |
259 |
|
"movb %%al,regflags\n\t" \ |
260 |
|
"movb %%ah,regflags+1\n\t" \ |
264 |
|
|
265 |
|
#define optflag_addw(v, s, d) do { \ |
266 |
|
__asm__ __volatile__ ("addw %w1,%w0\n\t" \ |
267 |
< |
"lahf\n\t" \ |
267 |
> |
ASM_LAHF "\n\t" \ |
268 |
|
"seto %%al\n\t" \ |
269 |
|
"movb %%al,regflags\n\t" \ |
270 |
|
"movb %%ah,regflags+1\n\t" \ |
274 |
|
|
275 |
|
#define optflag_addb(v, s, d) do { \ |
276 |
|
__asm__ __volatile__ ("addb %b1,%b0\n\t" \ |
277 |
< |
"lahf\n\t" \ |
277 |
> |
ASM_LAHF "\n\t" \ |
278 |
|
"seto %%al\n\t" \ |
279 |
|
"movb %%al,regflags\n\t" \ |
280 |
|
"movb %%ah,regflags+1\n\t" \ |
284 |
|
|
285 |
|
#define optflag_subl(v, s, d) do { \ |
286 |
|
__asm__ __volatile__ ("subl %k1,%k0\n\t" \ |
287 |
< |
"lahf\n\t" \ |
287 |
> |
ASM_LAHF "\n\t" \ |
288 |
|
"seto %%al\n\t" \ |
289 |
|
"movb %%al,regflags\n\t" \ |
290 |
|
"movb %%ah,regflags+1\n\t" \ |
294 |
|
|
295 |
|
#define optflag_subw(v, s, d) do { \ |
296 |
|
__asm__ __volatile__ ("subw %w1,%w0\n\t" \ |
297 |
< |
"lahf\n\t" \ |
297 |
> |
ASM_LAHF "\n\t" \ |
298 |
|
"seto %%al\n\t" \ |
299 |
|
"movb %%al,regflags\n\t" \ |
300 |
|
"movb %%ah,regflags+1\n\t" \ |
304 |
|
|
305 |
|
#define optflag_subb(v, s, d) do { \ |
306 |
|
__asm__ __volatile__ ("subb %b1,%b0\n\t" \ |
307 |
< |
"lahf\n\t" \ |
307 |
> |
ASM_LAHF "\n\t" \ |
308 |
|
"seto %%al\n\t" \ |
309 |
|
"movb %%al,regflags\n\t" \ |
310 |
|
"movb %%ah,regflags+1\n\t" \ |
314 |
|
|
315 |
|
#define optflag_cmpl(s, d) \ |
316 |
|
__asm__ __volatile__ ("cmpl %k0,%k1\n\t" \ |
317 |
< |
"lahf\n\t" \ |
317 |
> |
ASM_LAHF "\n\t" \ |
318 |
|
"seto %%al\n\t" \ |
319 |
|
"movb %%al,regflags\n\t" \ |
320 |
|
"movb %%ah,regflags+1\n\t" \ |
322 |
|
|
323 |
|
#define optflag_cmpw(s, d) \ |
324 |
|
__asm__ __volatile__ ("cmpw %w0,%w1\n\t" \ |
325 |
< |
"lahf\n\t" \ |
325 |
> |
ASM_LAHF "\n\t" \ |
326 |
|
"seto %%al\n\t" \ |
327 |
|
"movb %%al,regflags\n\t" \ |
328 |
|
"movb %%ah,regflags+1\n\t" \ |
330 |
|
|
331 |
|
#define optflag_cmpb(s, d) \ |
332 |
|
__asm__ __volatile__ ("cmpb %b0,%b1\n\t" \ |
333 |
< |
"lahf\n\t" \ |
333 |
> |
ASM_LAHF "\n\t" \ |
334 |
|
"seto %%al\n\t" \ |
335 |
|
"movb %%al,regflags\n\t" \ |
336 |
|
"movb %%ah,regflags+1\n\t" \ |