1 |
< |
/* |
2 |
< |
* UAE - The Un*x Amiga Emulator |
3 |
< |
* |
4 |
< |
* MC68000 emulation - machine dependent bits |
5 |
< |
* |
6 |
< |
* Copyright 1996 Bernd Schmidt |
7 |
< |
*/ |
1 |
> |
/* |
2 |
> |
* UAE - The Un*x Amiga Emulator |
3 |
> |
* |
4 |
> |
* MC68000 emulation - machine dependent bits |
5 |
> |
* |
6 |
> |
* Copyright 1996 Bernd Schmidt |
7 |
> |
* |
8 |
> |
* This program is free software; you can redistribute it and/or modify |
9 |
> |
* it under the terms of the GNU General Public License as published by |
10 |
> |
* the Free Software Foundation; either version 2 of the License, or |
11 |
> |
* (at your option) any later version. |
12 |
> |
* |
13 |
> |
* This program is distributed in the hope that it will be useful, |
14 |
> |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
> |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
> |
* GNU General Public License for more details. |
17 |
> |
* |
18 |
> |
* You should have received a copy of the GNU General Public License |
19 |
> |
* along with this program; if not, write to the Free Software |
20 |
> |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
> |
*/ |
22 |
|
|
23 |
|
#ifndef M68K_FLAGS_H |
24 |
|
#define M68K_FLAGS_H |
233 |
|
return 0; |
234 |
|
} |
235 |
|
|
236 |
+ |
/* Manually emit LAHF instruction so that 64-bit assemblers can grok it */ |
237 |
+ |
#if defined __x86_64__ && defined __GNUC__ |
238 |
+ |
#define ASM_LAHF ".byte 0x9f" |
239 |
+ |
#else |
240 |
+ |
#define ASM_LAHF "lahf" |
241 |
+ |
#endif |
242 |
+ |
|
243 |
|
/* Is there any way to do this without declaring *all* memory clobbered? |
244 |
|
I.e. any way to tell gcc that some byte-sized value is in %al? */ |
245 |
|
#define optflag_testl(v) \ |
246 |
|
__asm__ __volatile__ ("andl %0,%0\n\t" \ |
247 |
< |
"lahf\n\t" \ |
247 |
> |
ASM_LAHF "\n\t" \ |
248 |
|
"seto %%al\n\t" \ |
249 |
|
"movb %%al,regflags\n\t" \ |
250 |
|
"movb %%ah,regflags+1\n\t" \ |
252 |
|
|
253 |
|
#define optflag_testw(v) \ |
254 |
|
__asm__ __volatile__ ("andw %w0,%w0\n\t" \ |
255 |
< |
"lahf\n\t" \ |
255 |
> |
ASM_LAHF "\n\t" \ |
256 |
|
"seto %%al\n\t" \ |
257 |
|
"movb %%al,regflags\n\t" \ |
258 |
|
"movb %%ah,regflags+1\n\t" \ |
260 |
|
|
261 |
|
#define optflag_testb(v) \ |
262 |
|
__asm__ __volatile__ ("andb %b0,%b0\n\t" \ |
263 |
< |
"lahf\n\t" \ |
263 |
> |
ASM_LAHF "\n\t" \ |
264 |
|
"seto %%al\n\t" \ |
265 |
|
"movb %%al,regflags\n\t" \ |
266 |
|
"movb %%ah,regflags+1\n\t" \ |
268 |
|
|
269 |
|
#define optflag_addl(v, s, d) do { \ |
270 |
|
__asm__ __volatile__ ("addl %k1,%k0\n\t" \ |
271 |
< |
"lahf\n\t" \ |
271 |
> |
ASM_LAHF "\n\t" \ |
272 |
|
"seto %%al\n\t" \ |
273 |
|
"movb %%al,regflags\n\t" \ |
274 |
|
"movb %%ah,regflags+1\n\t" \ |
278 |
|
|
279 |
|
#define optflag_addw(v, s, d) do { \ |
280 |
|
__asm__ __volatile__ ("addw %w1,%w0\n\t" \ |
281 |
< |
"lahf\n\t" \ |
281 |
> |
ASM_LAHF "\n\t" \ |
282 |
|
"seto %%al\n\t" \ |
283 |
|
"movb %%al,regflags\n\t" \ |
284 |
|
"movb %%ah,regflags+1\n\t" \ |
288 |
|
|
289 |
|
#define optflag_addb(v, s, d) do { \ |
290 |
|
__asm__ __volatile__ ("addb %b1,%b0\n\t" \ |
291 |
< |
"lahf\n\t" \ |
291 |
> |
ASM_LAHF "\n\t" \ |
292 |
|
"seto %%al\n\t" \ |
293 |
|
"movb %%al,regflags\n\t" \ |
294 |
|
"movb %%ah,regflags+1\n\t" \ |
298 |
|
|
299 |
|
#define optflag_subl(v, s, d) do { \ |
300 |
|
__asm__ __volatile__ ("subl %k1,%k0\n\t" \ |
301 |
< |
"lahf\n\t" \ |
301 |
> |
ASM_LAHF "\n\t" \ |
302 |
|
"seto %%al\n\t" \ |
303 |
|
"movb %%al,regflags\n\t" \ |
304 |
|
"movb %%ah,regflags+1\n\t" \ |
308 |
|
|
309 |
|
#define optflag_subw(v, s, d) do { \ |
310 |
|
__asm__ __volatile__ ("subw %w1,%w0\n\t" \ |
311 |
< |
"lahf\n\t" \ |
311 |
> |
ASM_LAHF "\n\t" \ |
312 |
|
"seto %%al\n\t" \ |
313 |
|
"movb %%al,regflags\n\t" \ |
314 |
|
"movb %%ah,regflags+1\n\t" \ |
318 |
|
|
319 |
|
#define optflag_subb(v, s, d) do { \ |
320 |
|
__asm__ __volatile__ ("subb %b1,%b0\n\t" \ |
321 |
< |
"lahf\n\t" \ |
321 |
> |
ASM_LAHF "\n\t" \ |
322 |
|
"seto %%al\n\t" \ |
323 |
|
"movb %%al,regflags\n\t" \ |
324 |
|
"movb %%ah,regflags+1\n\t" \ |
328 |
|
|
329 |
|
#define optflag_cmpl(s, d) \ |
330 |
|
__asm__ __volatile__ ("cmpl %k0,%k1\n\t" \ |
331 |
< |
"lahf\n\t" \ |
331 |
> |
ASM_LAHF "\n\t" \ |
332 |
|
"seto %%al\n\t" \ |
333 |
|
"movb %%al,regflags\n\t" \ |
334 |
|
"movb %%ah,regflags+1\n\t" \ |
336 |
|
|
337 |
|
#define optflag_cmpw(s, d) \ |
338 |
|
__asm__ __volatile__ ("cmpw %w0,%w1\n\t" \ |
339 |
< |
"lahf\n\t" \ |
339 |
> |
ASM_LAHF "\n\t" \ |
340 |
|
"seto %%al\n\t" \ |
341 |
|
"movb %%al,regflags\n\t" \ |
342 |
|
"movb %%ah,regflags+1\n\t" \ |
344 |
|
|
345 |
|
#define optflag_cmpb(s, d) \ |
346 |
|
__asm__ __volatile__ ("cmpb %b0,%b1\n\t" \ |
347 |
< |
"lahf\n\t" \ |
347 |
> |
ASM_LAHF "\n\t" \ |
348 |
|
"seto %%al\n\t" \ |
349 |
|
"movb %%al,regflags\n\t" \ |
350 |
|
"movb %%ah,regflags+1\n\t" \ |