1/*
2 * Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
3 *
4 * This program and the accompanying materials
5 * are licensed and made available under the terms and conditions of the BSD License
6 * which accompanies this distribution.  The full text of the license may be found at
7 * http://opensource.org/licenses/bsd-license.php
8 *
9 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 */
12
13#include <arm/asm_help.h>
14
15EnterARM(__udivsi3)
16  cmp  r1, #0
17  cmpne  r0, #0
18  stmfd  sp!, {r4, r5, r7, lr}
19  add  r7, sp, #8
20  beq  l2
21  clz  r2, r1
22  clz  r3, r0
23  rsb  r3, r3, r2
24  cmp  r3, #31
25  bhi  l2
26  ldmfdeq  sp!, {r4, r5, r7, pc}
27  add  r5, r3, #1
28  rsb  r3, r3, #31
29  mov  lr, #0
30  mov  r2, r0, asl r3
31  mov  ip, r0, lsr r5
32  mov  r4, lr
33  b  l8
34l9:
35  mov  r0, r2, lsr #31
36  orr  ip, r0, ip, asl #1
37  orr  r2, r3, lr
38  rsb  r3, ip, r1
39  sub  r3, r3, #1
40  and  r0, r1, r3, asr #31
41  mov  lr, r3, lsr #31
42  rsb  ip, r0, ip
43  add  r4, r4, #1
44l8:
45  cmp  r4, r5
46  mov  r3, r2, asl #1
47  bne  l9
48  orr  r0, r3, lr
49  ldmfd  sp!, {r4, r5, r7, pc}
50l2:
51  mov  r0, #0
52  ldmfd  sp!, {r4, r5, r7, pc}
53