blob: 48d37c0d24c420da6a2e317c939e4110bf61750b (
plain)
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
30
31
32
33
|
.text
.p2align 2,0x90
.globl mpdigdiv
mpdigdiv:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
leal 12(%esp), %ebp /* %ebp = FP for now */
movl 0(%ebp), %ebx /* dividend */
movl 0(%ebx), %eax
movl 4(%ebx), %edx
movl 4(%ebp), %ebx /* divisor */
movl 8(%ebp), %ebp /* quotient */
xorl %ecx, %ecx
cmpl %ebx, %edx /* dividend >= 2^32 * divisor */
jae divovfl
cmpl %ecx, %ebx /* divisor == 1 */
je divovfl
divl %ebx /* AX = DX:AX/BX */
movl %eax, (%ebp)
done:
/* Postlude */
popl %ebx
popl %ebp
ret
/* return all 1's */
divovfl:
notl %ecx
movl %ecx, (%ebp)
jmp done
|