|
|
1.1 root 1: //////////
2: / /usr/src/libm/i387/ceil87.s
3: / i387 mathematics library
4: / ceil(d), floor(d)
5: //////////
6:
7: RASIZE = 4
8:
9: .globl ceil
10: .globl floor
11: .globl _floor
12:
13: cwup = 0xBFF / round up NDP control word
14: cwdown = 0x7FF / round down NDP control word
15:
16: d = RASIZE / arg offset
17:
18: //////////
19: / double
20: / ceil(d)
21: / double d;
22: //////////
23:
24:
25: ceil:
26: fldl d(%esp) / Load argument d.
27: movw %ax, $cwup / New control word to AX.
28: jmp .L0
29:
30: //////////
31: / double
32: / floor(d)
33: / double d;
34: /
35: / _floor() rounds the NDP stacktop %st down to the int below.
36: / It saves and restores the current NDP control word.
37: //////////
38:
39: oldcw = 0 / old NDP control word offset off %esp
40: newcw = 2 / new NDP control word offset off %esp
41:
42: floor:
43: fldl d(%esp) / Load argument d.
44:
45: _floor: / d
46: movw %ax, $cwdown / New control word to AX.
47:
48: .L0: / d in %st, new control word in AX.
49: push %eax / Claim two words.
50: movw newcw(%esp),%ax / Save new control word.
51: fstcw oldcw(%esp) / Save old control word.
52: fldcw newcw(%esp) / Load new control word.
53: frndint / int(d)
54: fldcw oldcw(%esp) / Restore saved control word.
55: pop %eax / Clean stack.
56: ret
57:
58: / end of ceil87.s
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.