3
/* so have assembler macros */
4
/* Normally gcc for the 386 only allows 4 operands to an asm,
5
however we need 5 for divul. You can easily make gcc accept
6
more by changing one line in genconfig.c and then recompiling gcc
8
printf ("\n#define MAX_RECOG_OPERANDS %d\n", max_recog_operands_flag + 3);
12
rem=hl; f=divul(x,y,rem);
14
hl:x == f*y + rem is true */
16
#define divul(x,y,hiremainder) \
17
({ulong __x =(x),__y=(y); \
18
asm volatile("divl %3" \
19
:"=a" (__x),"=d" (hiremainder) \
20
:"0" (__x),"rm"(__y),"1" (hiremainder) ); \
25
f = mulul(a,b,h) <--> h:f == a*b
28
#define mulul(x,y,hiremainder) \
29
({ulong __x =(x),__y=(y); \
30
asm volatile("mull %3" \
31
:"=a" (__x),"=d" (hiremainder) \
32
:"0" (__x),"rm"(__y)); \
36
/* add_carry: add X and Y adding 1 to H if there was overflow
37
H is presumed to be small enough not to overflow
40
#define add_carry(x,y,h) \
42
asm volatile("addl %4,%1\n\tadcl $0,%0" \
43
:"=rm,rm" (h),"=r,m" (__res): "0,0" (h),"1,1" (x),"rmn,r"(y)); \
47
/* SET_MACHINE_CARRYSet the machine carry flag
48
if overflow = 1 other wise clear it.
51
#define SET_MACHINE_CARRY(overflow) \
52
asm volatile("addl $-1,%0" : "=r" (overflow) : "0" (overflow))
55
/* SET_OVERFLOW Set the overflow = the current carry code
56
Note that machine loads and mov's should not affect
60
#define SET_OVERFLOW \
61
asm volatile("movl $0,%0\n\tadcl $0,%0" \
65
#define SUBXCC(xp,yp)\
66
({unsigned long _res; asm volatile("sbbl %2,%0" \
67
:"=r,rm" (_res): "0,0" (xp) , "rm,r" (yp)); _res;})
69
#define ADDXCC(xp,yp)\
70
({unsigned long _res; asm volatile("adcl %2,%0" \
71
:"=r,m" (_res): "0,0" (xp) , "rm,r" (yp)); _res;})
73
/* index of the first non zero bit numbering from left */
74
/* don't think there is an instruction.
76
({ulong _res; asm ("bfffo %1{#0:#0},%0" : "=r" (_res): "rm" (x)); _res;})
89
#define BASE_COUNTER 0