2 * Copyright (C) 2000 Maciej W. Rozycki
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
11 #include <asm/sgidefs.h>
14 * No traps on overflows for any of these...
17 #define do_div64_32(res, high, low, base) ({ \
18 unsigned long __quot, __mod; \
19 unsigned long __cf, __tmp, __tmp2, __i; \
21 __asm__(".set push\n\t" \
23 ".set noreorder\n\t" \
29 "sll $1, %0, 0x1\n\t" \
30 "srl %3, %0, 0x1f\n\t" \
32 "sll %1, %1, 0x1\n\t" \
36 "sltu %5, %0, %z6\n\t" \
39 " addiu %4,%4,-1\n\t" \
40 "subu %0, %0, %z6\n\t" \
44 " srl %5, %1, 0x1f\n\t" \
46 : "=&r" (__mod), "=&r" (__tmp), "=&r" (__quot), "=&r" (__cf), \
47 "=&r" (__i), "=&r" (__tmp2) \
48 : "Jr" (base), "0" (high), "1" (low)); \
53 #define do_div(n, base) ({ \
54 unsigned long long __quot; \
55 unsigned long __upper, __low, __high, __mod; \
58 __high = __quot >> 32; \
63 __asm__("divu $0,%z2,%z3" \
64 : "=h" (__upper), "=l" (__high) \
65 : "Jr" (__high), "Jr" (base)); \
67 __mod = do_div64_32(__low, __upper, __low, base); \
70 __quot = __quot << 32 | __low; \
74 #endif /* _ASM_DIV64_H */