1 #------------------------------------------------------------------------------
3 # Copyright (c) 2011, ARM. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #------------------------------------------------------------------------------
19 GCC_ASM_EXPORT(__aeabi_uidiv)
20 GCC_ASM_EXPORT(__aeabi_uidivmod)
21 GCC_ASM_EXPORT(__aeabi_idiv)
22 GCC_ASM_EXPORT(__aeabi_idivmod)
24 # AREA Math, CODE, READONLY
35 ASM_PFX(__aeabi_uidiv):
36 ASM_PFX(__aeabi_uidivmod):
37 rsbs r12, r1, r0, LSR #4
39 bcc ASM_PFX(__arm_div4)
40 rsbs r12, r1, r0, LSR #8
41 bcc ASM_PFX(__arm_div8)
43 b ASM_PFX(__arm_div_large)
53 ASM_PFX(__aeabi_idiv):
54 ASM_PFX(__aeabi_idivmod):
56 bmi ASM_PFX(__arm_div_negative)
57 rsbs r12, r1, r0, LSR #1
59 bcc ASM_PFX(__arm_div1)
60 rsbs r12, r1, r0, LSR #4
61 bcc ASM_PFX(__arm_div4)
62 rsbs r12, r1, r0, LSR #8
63 bcc ASM_PFX(__arm_div8)
65 b ASM_PFX(__arm_div_large)
67 rsbs r12, r1, r0, LSR #7
68 subcs r0, r0, r1, LSL #7
70 rsbs r12, r1, r0,LSR #6
71 subcs r0, r0, r1, LSL #6
73 rsbs r12, r1, r0, LSR #5
74 subcs r0, r0, r1, LSL #5
76 rsbs r12, r1, r0, LSR #4
77 subcs r0, r0, r1, LSL #4
80 rsbs r12, r1, r0, LSR #3
81 subcs r0, r0, r1, LSL #3
83 rsbs r12, r1, r0, LSR #2
84 subcs r0, r0, r1, LSL #2
86 rsbs r12, r1, r0, LSR #1
87 subcs r0, r0, r1, LSL #1
94 ASM_PFX(__arm_div_negative):
95 ands r2, r1, #0x80000000
97 eors r3, r2, r0, ASR #32
99 rsbs r12, r1, r0, LSR #4
101 rsbs r12, r1, r0, LSR #8
103 ASM_PFX(__arm_div_large):
105 rsbs r12, r1, r0, LSR #8
106 orr r2, r2, #0xfc000000
109 rsbs r12, r1, r0, LSR #8
110 orr r2, r2, #0x3f00000
113 rsbs r12, r1, r0, LSR #8
115 orrcs r2, r2, #0x3f00
118 bcs ASM_PFX(__aeabi_idiv0)
122 rsbs r12, r1, r0, LSR #7
123 subcs r0, r0, r1, LSL #7
125 rsbs r12, r1, r0, LSR #6
126 subcs r0, r0, r1, LSL #6
128 rsbs r12, r1, r0, LSR #5
129 subcs r0, r0, r1, LSL #5
131 rsbs r12, r1, r0, LSR #4
132 subcs r0, r0, r1, LSL #4
135 rsbs r12, r1, r0, LSR #3
136 subcs r0, r0, r1, LSL #3
138 rsbs r12, r1, r0, LSR #2
139 subcs r0, r0, r1, LSL #2
142 rsbs r12, r1, r0, LSR #1
143 subcs r0, r0, r1, LSL #1
153 @ What to do about division by zero? For now, just return.
154 ASM_PFX(__aeabi_idiv0):