3
/* so have assembler macros */
6
rem=hl; f=divul(x,y,rem);
8
hl:x == f*y + rem is true */
10
#define divul(x,y,hiremainder) \
11
({ulong __x =(x),__y=(y); \
12
asm volatile("divul %3,%1:%0" \
13
:"=d" (__x),"=d" (hiremainder) \
14
:"0" (__x),"dmn"(__y),"1" (hiremainder) ); \
19
f = mulul(a,b,h) <--> h:f == a*b
22
#define mulul(x,y,hiremainder) \
23
({ulong __x =(x),__y=(y); \
24
asm volatile("mulul %3,%1:%0" \
25
:"=d" (__x),"=d" (hiremainder) \
26
:"0" (__x),"dmn"(__y),"1" (hiremainder) ); \
30
/* add_carry: add X and Y adding 1 to H if there was overflow
31
H is presumed to be small enough not to overflow
34
/* note we have to pass the dummy arg (__res) to addxl asm,
35
to force that addition to take first */
36
#define add_carry(x,y,h) \
39
asm volatile("addxl %2,%0" \
40
:"=d" (h): "0" (h) , "d" (ZERO),"d" (__res)); \
44
/* SET_MACHINE_CARRYSet the machine carry flag
45
if overflow = 1 other wise clear it.
48
#define SET_MACHINE_CARRY(overflow) \
49
asm volatile("addl #-1,%0" : "=d" (overflow) : "0" (overflow))
52
/* SET_OVERFLOW Set the overflow = the current carry code
53
Note that machine loads and mov's should not affect
57
#define SET_OVERFLOW \
58
asm volatile("clrl %0\n\taddxl %0,%0" \
62
#define SUBXCC(xp,yp)\
63
({unsigned plong _res; asm volatile("subxl %2,%0" \
64
:"=d" (_res): "0" (xp) , "d" (yp)); _res;})
66
#define ADDXCC(xp,yp)\
67
({unsigned plong _res; asm volatile("addxl %2,%0" \
68
:"=d" (_res): "0" (xp) , "d" (yp)); _res;})
70
/* The 'X' bit of the condition code won't be
71
affected by computing the jump label */
73
#define C_SWITCH_DOESNT_AFFECT_CARRY
75
/* index of the first non zero bit numbering from left */
78
({ulong _res; asm ("bfffo %1{#0:#0},%0" : "=d" (_res): "rm" (x)); _res;})
91
#define BASE_COUNTER -1