1 /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Richard Henderson <rth@tamu.edu>.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
23 # include <asm/gentrap.h>
26 # include <machine/pal.h>
53 /* find correct sign for input to unsigned divide loop. */
54 mov a1, modulus # e0 :
55 mov a2, divisor # .. e1 :
57 negq a2, tmp2 # .. e1 :
58 mov zero, quotient # e0 :
60 cmovlt a1, tmp1, modulus # e0 :
61 cmovlt a2, tmp2, divisor # .. e1 :
62 beq a2, $divbyzero # e1 :
65 /* shift divisor left. */
66 1: cmpult divisor, modulus, compare # e0 :
67 blt divisor, 2f # .. e1 :
68 addq divisor, divisor, divisor # e0 :
69 addq mask, mask, mask # .. e1 :
70 bne compare, 1b # e1 :
73 /* start to go right again. */
74 2: addq quotient, mask, tmp2 # e1 :
75 srl mask, 1, mask # .. e0 :
76 cmpule divisor, modulus, compare # e0 :
77 subq modulus, divisor, tmp1 # .. e1 :
78 cmovne compare, tmp2, quotient # e1 :
79 srl divisor, 1, divisor # .. e0 :
80 cmovne compare, tmp1, modulus # e0 :
81 bne mask, 2b # .. e1 :
83 /* find correct sign for result. */
84 xor a1, a2, compare # e0 :
85 negq quotient, tmp1 # .. e1 :
86 negq modulus, tmp2 # e0 :
87 cmovlt compare, tmp1, quotient # .. e1 :
88 cmovlt a1, tmp2, modulus # e1 :
90 /* and store it away in the structure. */
91 9: stq quotient, 0(a0) # .. e0 :
93 stq modulus, 8(a0) # .. e0 :
101 /* if trap returns, return zero. */
108 weak_alias(ldiv, lldiv)