1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
udiv32_arm:
    tst     r0, r0
    /* High bit must be unset, otherwise shift numerator right, caluclate,
       and correct results. As this case is very uncommon we want to avoid
       any other delays on the main path in handling it, so the long divide
       calls the short divide as a function. */
    bmi     10f
udiv31_arm:
    ARM_DIV_31_BODY r0, r1, r2, r3, ip, r0, r1
    bx      lr
    .size udiv32_arm, . - udiv32_arm

10:
    /* store original numerator and divisor, we'll need them to correct the
       result, */
    stmdb   sp, [r0, r1, lr]
    /* Call __div0 here if divisor is zero, otherwise it would report the wrong
       address.
    */
    cmp     r0, #0
    subeq   sp, #4
    bleq    __div0
    bl      udiv31arm;
    ldmdb   sp, [r2, r3, lr]
    movs    r2, r2, lsr #1
    adc     r1, r1, r1
    subs    r1, r1, r3
    adc     r0, r0, r0
    .size udiv32_arm, . - udiv32_arm