2 * File: arch/blackfin/lib/modsi3.S
7 * Description: This program computes 32 bit signed remainder. It calls div32 function
8 * for quotient estimation.
11 * Numerator/ Denominator in R0, R1
12 * R0 - returns remainder.
16 * Copyright 2004-2006 Analog Devices Inc.
18 * Bugs: Enter bugs at http://blackfin.uclinux.org/
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, see the file COPYING, or write
32 * to the Free Software Foundation, Inc.,
33 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
37 .type ___modsi3, STT_FUNC;
39 .type ___divsi3, STT_FUNC;
41 #ifdef CONFIG_ARITHMETIC_OPS_L1
50 IF CC JUMP .LRETURN_R0; /* Return 0, if numerator == 0 */
52 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == 0 */
54 IF CC JUMP .LRETURN_ZERO; /* Return 0, if numerator == denominator */
56 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == 1 */
58 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == -1 */
60 /* Valid input. Use __divsi3() to compute the quotient, and then
61 * derive the remainder from that. */
63 [--SP] = (R7:6); /* Push R7 and R6 */
64 [--SP] = RETS; /* and return address */
65 R7 = R0; /* Copy of R0 */
66 R6 = R1; /* Save for later */
67 SP += -12; /* Should always provide this space */
68 CALL ___divsi3; /* Compute signed quotient using ___divsi3()*/
70 R0 *= R6; /* Quotient * divisor */
71 R0 = R7 - R0; /* Dividend - (quotient * divisor) */
72 RETS = [SP++]; /* Get back return address */
73 (R7:6) = [SP++]; /* Pop registers R7 and R4 */
74 RTS; /* Store remainder */
81 .size ___modsi3, .-___modsi3