]> icculus.org git repositories - btb/d2x.git/blob - main/fvi_a.h
Enabled savegame thumbnails under OpenGL
[btb/d2x.git] / main / fvi_a.h
1 #ifndef _FVI_A_H
2 #define _FVI_A_H
3
4 #ifndef NO_ASM
5 #ifdef __WATCOMC__
6 int oflow_check(fix a,fix b);
7
8 #pragma aux oflow_check parm [eax] [ebx] value [eax] modify exact [eax ebx edx] = \
9    "cdq"                \
10     "xor eax,edx"   \
11     "sub eax,edx"   \
12     "xchg eax,ebx"  \
13    "cdq"                \
14     "xor eax,edx"   \
15     "sub eax,edx"   \
16     "imul ebx"      \
17     "sar  edx,15"   \
18     "or   dx,dx"    \
19     "setnz al"      \
20     "movzx eax,al";
21 #else
22 #ifdef __GNUC__
23 static inline int oflow_check(fix a,fix b) {
24   register int __ret;
25   int dummy;
26   __asm__ (
27     " cdq;"
28     " xorl  %%edx,%%eax;"
29     " subl  %%edx,%%eax;"
30     " xchgl %%ebx,%%eax;"
31     " cdq;"
32     " xorl  %%edx,%%eax;"
33     " subl  %%edx,%%eax;"
34     " imull  %%ebx;"
35     " sarl  $15,%%edx;"
36     " orw   %%dx,%%dx;"
37     " setnz %%al;"
38     " movzbl %%al,%%eax"
39      : "=a" (__ret), "=b" (dummy) : "a" (a), "1" (b) : "%edx");
40     return __ret;
41 }
42 #else
43 static int oflow_check(fix a,fix b) {
44         return 0; /* hoping the floating point fix-math is used */
45 }
46 /*#error unknown compiler*/
47 #endif
48 #endif
49
50 #else
51 static int oflow_check(fix a,fix b) {
52         return 0; /* hoping the floating point fix-math is used */
53 }
54 #endif
55
56 #endif