|
|
1.1 root 1: //////////
2: / libc/gen/i386/ldiv.s
3: / i386 C standard library.
4: / ANSI 4.10.6.2, 4.10.6.4.
5: //////////
6:
7: //////////
8: / #include <stdlib.h>
9: /
10: / div_t
11: / div(int numer, int denom)
12: /
13: / ldiv_t
14: / ldiv(long numer, long denom)
15: /
16: / Compute quotient and remainder of 'numer' by 'denom'.
17: / Return a pointer to a statically allocated div_t/ldiv_t object.
18: / Since int and long are both 32 bits, div() and ldiv() are identical.
19: //////////
20:
21: .data
22: quot: .long 0
23: rem: .long 0
24:
25: numer .equ 4
26: denom .equ numer + 4
27:
28: .text
29:
30: .globl div
31: .globl ldiv
32:
33: div:
34: ldiv:
35: movl %eax, numer(%esp) / Dividend to EAX
36: cdq / Sign-extend to EDX:EAX
37: idivl denom(%esp) / Divide by divisor
38: movl quot, %eax / Store quotient
39: movl rem, %edx / Store remainder
40: movl %eax, $quot / Return pointer to result in EAX
41: ret
42:
43: / end of libc/gen/i386/ldiv.s
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.