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 #------------------------------------------------------------------------------
17 GCC_ASM_EXPORT(__aeabi_uidiv)
18 GCC_ASM_EXPORT(__aeabi_uidivmod)
19 GCC_ASM_EXPORT(__aeabi_idiv)
20 GCC_ASM_EXPORT(__aeabi_idivmod)
22 # AREA Math, CODE, READONLY
33 ASM_PFX(__aeabi_uidiv):
34 ASM_PFX(__aeabi_uidivmod):
35 rsbs r12, r1, r0, LSR #4
37 bcc ASM_PFX(__arm_div4)
38 rsbs r12, r1, r0, LSR #8
39 bcc ASM_PFX(__arm_div8)
41 b ASM_PFX(__arm_div_large)
51 ASM_PFX(__aeabi_idiv):
52 ASM_PFX(__aeabi_idivmod):
54 bmi ASM_PFX(__arm_div_negative)
55 rsbs r12, r1, r0, LSR #1
57 bcc ASM_PFX(__arm_div1)
58 rsbs r12, r1, r0, LSR #4
59 bcc ASM_PFX(__arm_div4)
60 rsbs r12, r1, r0, LSR #8
61 bcc ASM_PFX(__arm_div8)
63 b ASM_PFX(__arm_div_large)
65 rsbs r12, r1, r0, LSR #7
66 subcs r0, r0, r1, LSL #7
68 rsbs r12, r1, r0,LSR #6
69 subcs r0, r0, r1, LSL #6
71 rsbs r12, r1, r0, LSR #5
72 subcs r0, r0, r1, LSL #5
74 rsbs r12, r1, r0, LSR #4
75 subcs r0, r0, r1, LSL #4
78 rsbs r12, r1, r0, LSR #3
79 subcs r0, r0, r1, LSL #3
81 rsbs r12, r1, r0, LSR #2
82 subcs r0, r0, r1, LSL #2
84 rsbs r12, r1, r0, LSR #1
85 subcs r0, r0, r1, LSL #1
92 ASM_PFX(__arm_div_negative):
93 ands r2, r1, #0x80000000
95 eors r3, r2, r0, ASR #32
97 rsbs r12, r1, r0, LSR #4
99 rsbs r12, r1, r0, LSR #8
101 ASM_PFX(__arm_div_large):
103 rsbs r12, r1, r0, LSR #8
104 orr r2, r2, #0xfc000000
107 rsbs r12, r1, r0, LSR #8
108 orr r2, r2, #0x3f00000
111 rsbs r12, r1, r0, LSR #8
113 orrcs r2, r2, #0x3f00
116 bcs ASM_PFX(__aeabi_idiv0)
120 rsbs r12, r1, r0, LSR #7
121 subcs r0, r0, r1, LSL #7
123 rsbs r12, r1, r0, LSR #6
124 subcs r0, r0, r1, LSL #6
126 rsbs r12, r1, r0, LSR #5
127 subcs r0, r0, r1, LSL #5
129 rsbs r12, r1, r0, LSR #4
130 subcs r0, r0, r1, LSL #4
133 rsbs r12, r1, r0, LSR #3
134 subcs r0, r0, r1, LSL #3
136 rsbs r12, r1, r0, LSR #2
137 subcs r0, r0, r1, LSL #2
140 rsbs r12, r1, r0, LSR #1
141 subcs r0, r0, r1, LSL #1
151 @ What to do about division by zero? For now, just return.
152 ASM_PFX(__aeabi_idiv0):