2 @ libgcc1 routines for ARM cpu.
3 @ Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk)
14 .type __udivsi3 ,function
24 @ Unless the divisor is very big, shift it up in multiples of
25 @ four bits, since this is the amount of unwinding in the main
26 @ division loop. Continue shifting until the divisor is
27 @ larger than the dividend.
28 cmp divisor, #0x10000000
29 cmpcc divisor, dividend
30 movcc divisor, divisor, lsl #4
31 movcc curbit, curbit, lsl #4
34 @ For very big divisors, we must shift it a bit at a time, or
35 @ we will be in danger of overflowing.
36 cmp divisor, #0x80000000
37 cmpcc divisor, dividend
38 movcc divisor, divisor, lsl #1
39 movcc curbit, curbit, lsl #1
42 @ Test for possible subtractions, and note which bits
43 @ are done in the result. On the final pass, this may subtract
44 @ too much from the dividend, but the result will be ok, since the
45 @ "bit" will have been shifted out at the bottom.
47 subcs dividend, dividend, divisor
48 orrcs result, result, curbit
49 cmp dividend, divisor, lsr #1
50 subcs dividend, dividend, divisor, lsr #1
51 orrcs result, result, curbit, lsr #1
52 cmp dividend, divisor, lsr #2
53 subcs dividend, dividend, divisor, lsr #2
54 orrcs result, result, curbit, lsr #2
55 cmp dividend, divisor, lsr #3
56 subcs dividend, dividend, divisor, lsr #3
57 orrcs result, result, curbit, lsr #3
58 cmp dividend, #0 @ Early termination?
59 movnes curbit, curbit, lsr #4 @ No, any more bits to do?
60 movne divisor, divisor, lsr #4
68 mov r0, #0 @ about as wrong as it could be
70 .size __udivsi3 , . - __udivsi3
71 /* # 235 "libgcc1.S" */
72 /* # 320 "libgcc1.S" */
73 /* # 421 "libgcc1.S" */
74 /* # 433 "libgcc1.S" */
75 /* # 456 "libgcc1.S" */
76 /* # 500 "libgcc1.S" */
77 /* # 580 "libgcc1.S" */