/*1* This program computes 32 bit signed remainder. It calls div32 function2* for quotient estimation.3* Registers in: R0, R1 = Numerator/ Denominator4* Registers out: R0 = Remainder5*6* Copyright 2004-2009 Analog Devices Inc.7*8* Licensed under the ADI BSD license or the GPL-2 (or later)9*/1011.global ___modsi3;12.type ___modsi3, STT_FUNC;13.extern ___divsi3;14.type ___divsi3, STT_FUNC;1516#ifdef CONFIG_ARITHMETIC_OPS_L117.section .l1.text18#else19.text20#endif2122___modsi3:2324CC=R0==0;25IF CC JUMP .LRETURN_R0; /* Return 0, if numerator == 0 */26CC=R1==0;27IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == 0 */28CC=R0==R1;29IF CC JUMP .LRETURN_ZERO; /* Return 0, if numerator == denominator */30CC = R1 == 1;31IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == 1 */32CC = R1 == -1;33IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == -1 */3435/* Valid input. Use __divsi3() to compute the quotient, and then36* derive the remainder from that. */3738[--SP] = (R7:6); /* Push R7 and R6 */39[--SP] = RETS; /* and return address */40R7 = R0; /* Copy of R0 */41R6 = R1; /* Save for later */42SP += -12; /* Should always provide this space */43CALL ___divsi3; /* Compute signed quotient using ___divsi3()*/44SP += 12;45R0 *= R6; /* Quotient * divisor */46R0 = R7 - R0; /* Dividend - (quotient * divisor) */47RETS = [SP++]; /* Get back return address */48(R7:6) = [SP++]; /* Pop registers R7 and R4 */49RTS; /* Store remainder */5051.LRETURN_ZERO:52R0 = 0;53.LRETURN_R0:54RTS;5556.size ___modsi3, .-___modsi3575859