|
|
1.1 root 1: //////////
2: / libc/crt/i386/ducvt.s
3: / i386 C runtime library.
4: / IEEE software floating point support.
5: //////////
6:
7: //////////
8: / double _ducvt()
9: / Convert unsigned int in %eax to double, return in %edx:%eax.
10: /
11: / There is no 32-bit shift, so the code below uses an n-1 bit shift
12: / followed by a 1 bit shift rather than an n-bit shift;
13: / this gets (double)1 right without a special case.
14: //////////
15:
16: BIAS .equ 1023
17:
18: .globl _ducvt
19:
20: _ducvt:
21: bsrl %edx, %eax / high bit position 0-31 to EDX (DL)
22: jz ?zero / return 0.0
23: push %ecx
24: movb %cl, $31
25: subb %cl, %dl / shift count - 1 to CL
26: shll %eax, %cl / high bit lands at bit 31
27: shll %eax, $1 / hidden bit into CF
28: movl %ecx, %edx
29: addl %ecx, $BIAS / biased exponent to ECX
30: shll %ecx, $20 / position biased exponent
31: movl %edx, %eax
32: shrl %edx, $12 / hi manissa to EDX
33: shll %eax, $20 / lo mantissa to EAX
34: orl %edx, %ecx / exponent
35: pop %ecx
36: ret
37:
38: ?zero:
39: sub %edx, %edx
40: ret
41:
42: / end of libc/crt/i386/ducvt.s
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.