1#------------------------------------------------------------------------------
2#
3# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4#
5# SPDX-License-Identifier: BSD-2-Clause-Patent
6#
7#------------------------------------------------------------------------------
8
9#include <AsmMacroIoLib.h>
10
11  .syntax unified
12
13ASM_FUNC(__udivsi3)
14  cmp  r1, #0
15  cmpne  r0, #0
16  stmfd  sp!, {r4, r5, r7, lr}
17  add  r7, sp, #8
18  beq  L2
19  clz  r2, r1
20  clz  r3, r0
21  rsb  r3, r3, r2
22  cmp  r3, #31
23  bhi  L2
24  ldmfdeq  sp!, {r4, r5, r7, pc}
25  add  r5, r3, #1
26  rsb  r3, r3, #31
27  mov  lr, #0
28  mov  r2, r0, asl r3
29  mov  ip, r0, lsr r5
30  mov  r4, lr
31  b  L8
32L9:
33  mov  r0, r2, lsr #31
34  orr  ip, r0, ip, asl #1
35  orr  r2, r3, lr
36  rsb  r3, ip, r1
37  sub  r3, r3, #1
38  and  r0, r1, r3, asr #31
39  mov  lr, r3, lsr #31
40  rsb  ip, r0, ip
41  add  r4, r4, #1
42L8:
43  cmp  r4, r5
44  mov  r3, r2, asl #1
45  bne  L9
46  orr  r0, r3, lr
47  ldmfd  sp!, {r4, r5, r7, pc}
48L2:
49  mov  r0, #0
50  ldmfd  sp!, {r4, r5, r7, pc}
51
52