1//------------------------------------------------------------------------------ 2// 3// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> 4// 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 9// 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. 12// 13//------------------------------------------------------------------------------ 14 15 16 17 18 INCLUDE AsmMacroExport.inc 19 20; 21;UINT64 22;EFIAPI 23;__aeabi_uldivmod ( 24; IN UINT64 Dividend 25; IN UINT64 Divisor 26; ) 27; 28 RVCT_ASM_EXPORT __aeabi_uldivmod 29 stmdb sp!, {r4, r5, r6, lr} 30 mov r4, r1 31 mov r5, r0 32 mov r6, #0 ; 0x0 33 orrs ip, r3, r2, lsr #31 34 bne __aeabi_uldivmod_label1 35 tst r2, r2 36 beq _ll_div0 37 movs ip, r2, lsr #15 38 addeq r6, r6, #16 ; 0x10 39 mov ip, r2, lsl r6 40 movs lr, ip, lsr #23 41 moveq ip, ip, lsl #8 42 addeq r6, r6, #8 ; 0x8 43 movs lr, ip, lsr #27 44 moveq ip, ip, lsl #4 45 addeq r6, r6, #4 ; 0x4 46 movs lr, ip, lsr #29 47 moveq ip, ip, lsl #2 48 addeq r6, r6, #2 ; 0x2 49 movs lr, ip, lsr #30 50 moveq ip, ip, lsl #1 51 addeq r6, r6, #1 ; 0x1 52 b _ll_udiv_small 53__aeabi_uldivmod_label1 54 tst r3, #-2147483648 ; 0x80000000 55 bne __aeabi_uldivmod_label2 56 movs ip, r3, lsr #15 57 addeq r6, r6, #16 ; 0x10 58 mov ip, r3, lsl r6 59 movs lr, ip, lsr #23 60 moveq ip, ip, lsl #8 61 addeq r6, r6, #8 ; 0x8 62 movs lr, ip, lsr #27 63 moveq ip, ip, lsl #4 64 addeq r6, r6, #4 ; 0x4 65 movs lr, ip, lsr #29 66 moveq ip, ip, lsl #2 67 addeq r6, r6, #2 ; 0x2 68 movs lr, ip, lsr #30 69 addeq r6, r6, #1 ; 0x1 70 rsb r3, r6, #32 ; 0x20 71 moveq ip, ip, lsl #1 72 orr ip, ip, r2, lsr r3 73 mov lr, r2, lsl r6 74 b _ll_udiv_big 75__aeabi_uldivmod_label2 76 mov ip, r3 77 mov lr, r2 78 b _ll_udiv_ginormous 79 80_ll_udiv_small 81 cmp r4, ip, lsl #1 82 mov r3, #0 ; 0x0 83 subcs r4, r4, ip, lsl #1 84 addcs r3, r3, #2 ; 0x2 85 cmp r4, ip 86 subcs r4, r4, ip 87 adcs r3, r3, #0 ; 0x0 88 add r2, r6, #32 ; 0x20 89 cmp r2, #32 ; 0x20 90 rsb ip, ip, #0 ; 0x0 91 bcc _ll_udiv_small_label1 92 orrs r0, r4, r5, lsr #30 93 moveq r4, r5 94 moveq r5, #0 ; 0x0 95 subeq r2, r2, #32 ; 0x20 96_ll_udiv_small_label1 97 mov r1, #0 ; 0x0 98 cmp r2, #16 ; 0x10 99 bcc _ll_udiv_small_label2 100 movs r0, r4, lsr #14 101 moveq r4, r4, lsl #16 102 addeq r1, r1, #16 ; 0x10 103_ll_udiv_small_label2 104 sub lr, r2, r1 105 cmp lr, #8 ; 0x8 106 bcc _ll_udiv_small_label3 107 movs r0, r4, lsr #22 108 moveq r4, r4, lsl #8 109 addeq r1, r1, #8 ; 0x8 110_ll_udiv_small_label3 111 rsb r0, r1, #32 ; 0x20 112 sub r2, r2, r1 113 orr r4, r4, r5, lsr r0 114 mov r5, r5, lsl r1 115 cmp r2, #1 ; 0x1 116 bcc _ll_udiv_small_label5 117 sub r2, r2, #1 ; 0x1 118 and r0, r2, #7 ; 0x7 119 eor r0, r0, #7 ; 0x7 120 adds r0, r0, r0, lsl #1 121 add pc, pc, r0, lsl #2 122 nop ; (mov r0,r0) 123_ll_udiv_small_label4 124 adcs r5, r5, r5 125 adcs r4, ip, r4, lsl #1 126 rsbcc r4, ip, r4 127 adcs r5, r5, r5 128 adcs r4, ip, r4, lsl #1 129 rsbcc r4, ip, r4 130 adcs r5, r5, r5 131 adcs r4, ip, r4, lsl #1 132 rsbcc r4, ip, r4 133 adcs r5, r5, r5 134 adcs r4, ip, r4, lsl #1 135 rsbcc r4, ip, r4 136 adcs r5, r5, r5 137 adcs r4, ip, r4, lsl #1 138 rsbcc r4, ip, r4 139 adcs r5, r5, r5 140 adcs r4, ip, r4, lsl #1 141 rsbcc r4, ip, r4 142 adcs r5, r5, r5 143 adcs r4, ip, r4, lsl #1 144 rsbcc r4, ip, r4 145 adcs r5, r5, r5 146 adcs r4, ip, r4, lsl #1 147 sub r2, r2, #8 ; 0x8 148 tst r2, r2 149 rsbcc r4, ip, r4 150 bpl _ll_udiv_small_label4 151_ll_udiv_small_label5 152 mov r2, r4, lsr r6 153 bic r4, r4, r2, lsl r6 154 adcs r0, r5, r5 155 adc r1, r4, r4 156 add r1, r1, r3, lsl r6 157 mov r3, #0 ; 0x0 158 ldmia sp!, {r4, r5, r6, pc} 159 160_ll_udiv_big 161 subs r0, r5, lr 162 mov r3, #0 ; 0x0 163 sbcs r1, r4, ip 164 movcs r5, r0 165 movcs r4, r1 166 adcs r3, r3, #0 ; 0x0 167 subs r0, r5, lr 168 sbcs r1, r4, ip 169 movcs r5, r0 170 movcs r4, r1 171 adcs r3, r3, #0 ; 0x0 172 subs r0, r5, lr 173 sbcs r1, r4, ip 174 movcs r5, r0 175 movcs r4, r1 176 adcs r3, r3, #0 ; 0x0 177 mov r1, #0 ; 0x0 178 rsbs lr, lr, #0 ; 0x0 179 rsc ip, ip, #0 ; 0x0 180 cmp r6, #16 ; 0x10 181 bcc _ll_udiv_big_label1 182 movs r0, r4, lsr #14 183 moveq r4, r4, lsl #16 184 addeq r1, r1, #16 ; 0x10 185_ll_udiv_big_label1 186 sub r2, r6, r1 187 cmp r2, #8 ; 0x8 188 bcc _ll_udiv_big_label2 189 movs r0, r4, lsr #22 190 moveq r4, r4, lsl #8 191 addeq r1, r1, #8 ; 0x8 192_ll_udiv_big_label2 193 rsb r0, r1, #32 ; 0x20 194 sub r2, r6, r1 195 orr r4, r4, r5, lsr r0 196 mov r5, r5, lsl r1 197 cmp r2, #1 ; 0x1 198 bcc _ll_udiv_big_label4 199 sub r2, r2, #1 ; 0x1 200 and r0, r2, #3 ; 0x3 201 rsb r0, r0, #3 ; 0x3 202 adds r0, r0, r0, lsl #1 203 add pc, pc, r0, lsl #3 204 nop ; (mov r0,r0) 205_ll_udiv_big_label3 206 adcs r5, r5, r5 207 adcs r4, r4, r4 208 adcs r0, lr, r5 209 adcs r1, ip, r4 210 movcs r5, r0 211 movcs r4, r1 212 adcs r5, r5, r5 213 adcs r4, r4, r4 214 adcs r0, lr, r5 215 adcs r1, ip, r4 216 movcs r5, r0 217 movcs r4, r1 218 adcs r5, r5, r5 219 adcs r4, r4, r4 220 adcs r0, lr, r5 221 adcs r1, ip, r4 222 movcs r5, r0 223 movcs r4, r1 224 sub r2, r2, #4 ; 0x4 225 adcs r5, r5, r5 226 adcs r4, r4, r4 227 adcs r0, lr, r5 228 adcs r1, ip, r4 229 tst r2, r2 230 movcs r5, r0 231 movcs r4, r1 232 bpl _ll_udiv_big_label3 233_ll_udiv_big_label4 234 mov r1, #0 ; 0x0 235 mov r2, r5, lsr r6 236 bic r5, r5, r2, lsl r6 237 adcs r0, r5, r5 238 adc r1, r1, #0 ; 0x0 239 movs lr, r3, lsl r6 240 mov r3, r4, lsr r6 241 bic r4, r4, r3, lsl r6 242 adc r1, r1, #0 ; 0x0 243 adds r0, r0, lr 244 orr r2, r2, r4, ror r6 245 adc r1, r1, #0 ; 0x0 246 ldmia sp!, {r4, r5, r6, pc} 247 248_ll_udiv_ginormous 249 subs r2, r5, lr 250 mov r1, #0 ; 0x0 251 sbcs r3, r4, ip 252 adc r0, r1, r1 253 movcc r2, r5 254 movcc r3, r4 255 ldmia sp!, {r4, r5, r6, pc} 256 257_ll_div0 258 ldmia sp!, {r4, r5, r6, lr} 259 mov r0, #0 ; 0x0 260 mov r1, #0 ; 0x0 261 b __aeabi_ldiv0 262 263__aeabi_ldiv0 264 BX r14 265 266 END 267 268