Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 2 | * libgcc1 routines for Blackfin 5xx |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 3 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 4 | * Copyright 2004-2009 Analog Devices Inc. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 5 | * |
Sonic Zhang | de45083 | 2012-05-17 14:45:27 +0800 | [diff] [blame] | 6 | * Licensed under the Clear BSD license or the GPL-2 (or later) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifdef CONFIG_ARITHMETIC_OPS_L1 |
| 10 | .section .l1.text |
| 11 | #else |
| 12 | .text |
| 13 | #endif |
| 14 | |
| 15 | .extern ___udivsi3; |
Mike Frysinger | 51be24c | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 16 | .type ___udivsi3, STT_FUNC; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 17 | .globl ___umodsi3 |
Mike Frysinger | 51be24c | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 18 | .type ___umodsi3, STT_FUNC; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 19 | ___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 Frysinger | 51be24c | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 48 | |
| 49 | .size ___umodsi3, .-___umodsi3 |