|
|
1.1 root 1: //////////
2: / libc/crt/i386/dfcvt.s
3: / i386 C runtime library.
4: / IEEE software floating point support.
5: //////////
6:
7: //////////
8: / double _dfcvt()
9: / Convert float in %eax to double, return in %edx:%eax.
10: / Ignores denormals and NaNs.
11: //////////
12:
13: BIAS .equ 1023
14: FBIAS .equ 127
15: SGNMASK .equ 0x80000000
16: EXPMASK .equ 0x7FF00000
17: FEXPMASK .equ 0x7F800000
18: FMANMASK .equ 0x007FFFFF
19: FMAXEXP .equ 255
20:
21: .globl _dfcvt
22:
23: _dfcvt:
24: push %ecx
25: subl %edx, %edx / 0 to EDX
26: movl %ecx, %eax / copy float to ECX
27: andl %ecx, $FEXPMASK / extract float exponent
28: jz ?zero / return 0.0, ignoring denormals
29: orl %eax, %eax
30: pushfl / save arg flag
31: shrl %ecx, $23 / unshift float exponent
32: cmpl %ecx, $FMAXEXP / check for big exponent
33: jz ?inf / return +-infinity, ignoring NaNs
34: addl %ecx, $BIAS-FBIAS / adjust to double exponent bias
35: shll %ecx, $20 / double exponent to correct position
36: and %eax, $FMANMASK / extract float mantissa in EAX
37: movl %edx, %eax / and copy to EDX
38: shrl %edx, $3 / shift hi mantissa
39: shll %eax, $29 / and lo mantissa
40: orl %edx, %ecx / exponent
41:
42: ?setsign:
43: popfl / restore arg sign flag
44: jns ?L0
45: orl %edx, $SGNMASK / set sign bit
46: ?L0:
47: pop %ecx
48: ret
49:
50: ?inf:
51: movl %edx, $EXPMASK
52: subl %eax, %eax
53: jmp ?setsign
54:
55: ?zero:
56: subl %eax, %eax / EDX is already 0, return 0.0
57: pop %ecx
58: ret
59:
60: / end of libc/crt/i386/dfcvt.s
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.