2 * This program computes 32 bit signed remainder. It calls div32 function
3 * for quotient estimation.
4 * Registers in: R0, R1 = Numerator/ Denominator
5 * Registers out: R0 = Remainder
7 * Copyright 2004-2009 Analog Devices Inc.
9 * Licensed under the Clear BSD license or the GPL-2 (or later)
13 .type ___modsi3, STT_FUNC;
15 .type ___divsi3, STT_FUNC;
17 #ifdef CONFIG_ARITHMETIC_OPS_L1
26 IF CC JUMP .LRETURN_R0; /* Return 0, if numerator == 0 */
28 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == 0 */
30 IF CC JUMP .LRETURN_ZERO; /* Return 0, if numerator == denominator */
32 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == 1 */
34 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == -1 */
36 /* Valid input. Use __divsi3() to compute the quotient, and then
37 * derive the remainder from that. */
39 [--SP] = (R7:6); /* Push R7 and R6 */
40 [--SP] = RETS; /* and return address */
41 R7 = R0; /* Copy of R0 */
42 R6 = R1; /* Save for later */
43 SP += -12; /* Should always provide this space */
44 CALL ___divsi3; /* Compute signed quotient using ___divsi3()*/
46 R0 *= R6; /* Quotient * divisor */
47 R0 = R7 - R0; /* Dividend - (quotient * divisor) */
48 RETS = [SP++]; /* Get back return address */
49 (R7:6) = [SP++]; /* Pop registers R7 and R4 */
50 RTS; /* Store remainder */
57 .size ___modsi3, .-___modsi3