1: /*
2: * @(#)udiv.s 7.1 (Berkeley) 6/5/86
3: *
4: * udiv - unsigned division for vax-11
5: *
6: * arguments: dividend, divisor.
7: * result: quotient.
8: * uses r0-r2
9: *
10: * If 1 < divisor <= 2147483647, zero-extend the dividend
11: * to 64 bits and let ediv do the work. If the divisor is 1,
12: * ediv will overflow if bit 31 of the dividend is on, so
13: * just return the dividend unchanged. If the divisor is 0,
14: * do the ediv also, so it will generate the proper exception.
15: * All other values of the divisor have bit 31 on: in this case
16: * the quotient must be 0 if divisor > dividend, and 1 otherwise,
17: * provided that the comparison is made as unsigned.
18: */
19: .text
20: .align 1
21: .globl udiv
22: udiv: .word 0x0000
23: #ifdef GPROF
24: jsb mcount
25: #endif GPROF
26: movl 4(ap),r0 # Dividend
27: movl 8(ap),r2 # Divisor
28: jeql div # If divisor=0, force exception
29: cmpl r2,$1 # If divisor <= 1 (signed),
30: jleq nodiv # no division is necessary
31: div: clrl r1 # Zero-extend the dividend
32: ediv r2,r0,r0,r2 # Divide. q->r0, r->r2 (discarded)
33: ret
34: nodiv: jeql retn # If divisor=1, return dividend
35: cmpl r0,r2 # Unsigned comparison between
36: jgequ one # dividend and divisor
37: clrl r0 # Dividend < divisor, return 0
38: ret
39: one: movl $1,r0 # Dividend >= divisor, return 1
40: retn: ret
Defined functions
nodiv
defined in line
34; used 1 times
one
defined in line
39; used 1 times
retn
defined in line
40; used 1 times
udiv
declared in line
21; defined in line
22; used 1 times