1 ; libgcc routines for ARC cpu.
3 /* Copyright (C) 1995, 1997,2004 Free Software Foundation, Inc.
5 This file is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 In addition to the permissions in the GNU General Public License, the
11 Free Software Foundation gives you unlimited permission to link the
12 compiled version of this file into combinations with other programs,
13 and to distribute those combinations without any restriction coming
14 from the use of this file. (The General Public License restrictions
15 do apply in other respects; for example, they cover modification of
16 the file, and distribution when not linked into a combine
19 This file is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with GCC; see the file COPYING. If not, write to
26 the Free Software Foundation, 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. */
38 /* This the simple version.
48 mov r2,0 ; Accumulate result here.
50 sub.f 0,r0,0 ; while (a)
53 and.f 0,r0,1 ; if (a & 1)
54 add.nz r2,r2,r1 ; r += b
74 /* This the simple version.
84 mov r2,0 ; Top part of b.
85 mov r3,0 ; Accumulate result here.
88 sub.f 0,r0,0 ; while (a)
91 and.f 0,r0,1 ; if (a & 1)
95 add.f r4,r4,r1 ; r += b
103 #ifdef __big_endian__
114 #endif /* L_umulsidi3 */
116 #ifdef L_divmod_tools
118 ; Utilities used by all routines.
123 ; inputs: r0 = numerator, r1 = denominator
124 ; outputs: positive r0/r1,
125 ; r6.bit1 = sign of numerator, r6.bit0 = sign of result
129 mov r6,0 ; keep sign in r6
130 sub.f 0,r0,0 ; is numerator -ve?
131 sub.lt r0,0,r0 ; negate numerator
132 mov.lt r6,3 ; sign is -ve
133 sub.f 0,r1,0 ; is denominator -ve?
134 sub.lt r1,0,r1 ; negate denominator
135 xor.lt r6,r6,1 ; toggle sign
140 udivmodsi4(int modwanted, unsigned long num, unsigned long den)
142 unsigned long bit = 1;
143 unsigned long res = 0;
145 while (den < num && bit && !(den & (1L<<31)))
160 if (modwanted) return num;
165 ; inputs: r0 = numerator, r1 = denominator
166 ; outputs: r0 = quotient, r1 = remainder, r2/r3 trashed
168 .global ___udivmodsi4
173 sub.f 0,r1,r0 ; while (den < num
176 sub.f 0,r2,0 ; && bit
179 lsl.f 0,r1 ; && !(den & (1<<31))
182 lsl r1,r1 ; den <<= 1
184 lsl r2,r2 ; bit <<= 1
186 sub.f 0,r2,0 ; while (bit)
189 sub.f 0,r0,r1 ; if (num >= den)
192 sub r0,r0,r1 ; num -= den
193 or r3,r3,r2 ; res |= bit
195 lsr r2,r2 ; bit >>= 1
197 lsr r1,r1 ; den >>= 1
218 #endif /* L_udivsi3 */
232 sub.nz r0,0,r0 ; cannot go in delay slot, has limm value
236 #endif /* L_divsi3 */
252 #endif /* L_umodsi3 */
271 #endif /* L_modsi3 */