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