blob: 3794c00d859d4bf57c378d394d41428a9710b535 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * libgcc1 routines for Blackfin 5xx
Bryan Wu1394f032007-05-06 14:50:22 -07003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Copyright 2004-2009 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07005 *
Sonic Zhangde450832012-05-17 14:45:27 +08006 * Licensed under the Clear BSD license or the GPL-2 (or later)
Bryan Wu1394f032007-05-06 14:50:22 -07007 */
8
9#ifdef CONFIG_ARITHMETIC_OPS_L1
10.section .l1.text
11#else
12.text
13#endif
14
15.extern ___udivsi3;
Mike Frysinger51be24c2007-06-11 15:31:30 +080016.type ___udivsi3, STT_FUNC;
Bryan Wu1394f032007-05-06 14:50:22 -070017.globl ___umodsi3
Mike Frysinger51be24c2007-06-11 15:31:30 +080018.type ___umodsi3, STT_FUNC;
Bryan Wu1394f032007-05-06 14:50:22 -070019___umodsi3:
20
21 CC=R0==0;
22 IF CC JUMP .LRETURN_R0; /* Return 0, if NR == 0 */
23 CC= R1==0;
24 IF CC JUMP .LRETURN_ZERO_VAL; /* Return 0, if DR == 0 */
25 CC=R0==R1;
26 IF CC JUMP .LRETURN_ZERO_VAL; /* Return 0, if NR == DR */
27 CC = R1 == 1;
28 IF CC JUMP .LRETURN_ZERO_VAL; /* Return 0, if DR == 1 */
29 CC = R0<R1 (IU);
30 IF CC JUMP .LRETURN_R0; /* Return dividend (R0),IF NR<DR */
31
32 [--SP] = (R7:6); /* Push registers and */
33 [--SP] = RETS; /* Return address */
34 R7 = R0; /* Copy of R0 */
35 R6 = R1;
36 SP += -12; /* Should always provide this space */
37 CALL ___udivsi3; /* Compute unsigned quotient using ___udiv32()*/
38 SP += 12;
39 R0 *= R6; /* Quotient * divisor */
40 R0 = R7 - R0; /* Dividend - (quotient * divisor) */
41 RETS = [SP++]; /* Pop return address */
42 ( R7:6) = [SP++]; /* And registers */
43 RTS; /* Return remainder */
44.LRETURN_ZERO_VAL:
45 R0 = 0;
46.LRETURN_R0:
47 RTS;
Mike Frysinger51be24c2007-06-11 15:31:30 +080048
49.size ___umodsi3, .-___umodsi3