|
|
1.1 root 1: .data
2: .asciz "@(#)Fdtos.s 1.1 86/02/03 Copyr 1985 Sun Micro"
3: .even
4: .text
5:
6: | Copyright (c) 1985 by Sun Microsystems, Inc.
7:
8: #include "fpcrtdefs.h"
9:
10: RTENTRY(Fdtos)
11: movel d0,a0 | a0 saves x.
12: andl #0x7fffffff,d0 | Clear sign bit.
13: cmpl #0x38100000,d0
14: blts small | Branch if small exponent.
15: cmpl #0x47f00000,d0
16: bges big | Branch if big exponent.
17: subl #0x38000000,d0
18: lsll #1,d1 | Shift left three places.
19: roxll #1,d0
20: lsll #1,d1
21: roxll #1,d0
22: lsll #1,d1
23: roxll #1,d0
24: addl #0x80000000,d1 | Add round bit.
25: bccs 1f
26: addql #1,d0 | Propagate carry.
27: 1:
28: tstl d1
29: bnes sign | Branch if not ambiguous.
30: andl #0xfffffffe,d0 | Force round to even.
31: sign:
32: cmpl #0,a0
33: bges 1f | Branch if sign of x is positive.
34: orl #0x80000000,d0 | Set negative.
35: 1:
36: RET
37:
38: big:
39: cmpl #0x7ff00000,d0
40: bgts nan | Branch if nan.
41: blts inf | Branch if overflow.
42: tstl d1
43: bnes nan | Branch if nan.
44: inf:
45: movel #0x7f800000,d0 | Make inf.
46: clrl d1
47: bras sign
48: nan:
49: lsll #1,d1 | Shift left three places.
50: roxll #1,d0
51: lsll #1,d1
52: roxll #1,d0
53: lsll #1,d1
54: roxll #1,d0
55: orl #0x7fc00000,d0 | Force quiet nan.
56: bras sign
57: small:
58: cmpl #0x36900000,d0
59: bges subnorm | Branch if possible subnorm.
60: clrl d0
61: bras sign | Branch if zero.
62: subnorm:
63: lsll #1,d1 | Shift left three places.
64: roxll #1,d0
65: lsll #1,d1
66: roxll #1,d0
67: lsll #1,d1
68: roxll #1,d0
69: tstl d1
70: beqs 1f | Branch if no lower bits.
71: orl #0x80000000,d1 | Set sticky bit.
72: bras 2f
73: 1:
74: clrl d1 | Clear sticky bit.
75: 2:
76: swap d0
77: movew d0,d1
78: swap d0
79: lsrw #7,d1
80: andl #0x007fffff,d0 | Clear exponent.
81: orl #0x00800000,d0 | Set I bit.
82: subw #0x0180,d1 | Convert to shift count.
83: bges 2f
84:
85: norm:
86: lsrl #1,d0
87: bcc 1f
88: orl #0x80000000,d1 | Force sticky bit.
89: 1:
90: addqw #1,d1
91: blts norm
92:
93: 2:
94: addql #1,d0 | Round bit.
95: btst #0,d0
96: bnes 2f | Branch not ambiguous.
97: btst #31,d1
98: bnes 2f | Branch not ambiguous.
99: andl #0x01fffffc,d0 | Force round to even.
100: 2:
101: lsrl #1,d0 | Remove round bit.
102: jra sign
103:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.