|
|
1.1 root 1: .data
2: .asciz "@(#)Faintd.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(Farintd)
11: moveml d2-d4,sp@-
12: movel d0,d2 | d2 gets top(x).
13: bclr #31,d2 | d2 gets top(abs(x)).
14: cmpl #0x3ff00000,d2
15: bges 2f | Branch if abs(x) >= 1.0.
16: andl #0x80000000,d0 | Isolate sign of x.
17: cmpl #0x3fe00000,d2
18: blts 6f | Branch if abs(x) < 0.5.
19: tstl d1
20: beqs 7f | Branch if abs(x) = 0.5 exactly.
21: orl #0x3ff00000,d0 | Make signed 1.0.
22: 6:
23: clrl d1 | Clear lower part in any case.
24: 7:
25: jra Farintddone
26: 2:
27: cmpl #0x43300000,d2
28: blts 3f | Branch if 1 <= |x| < 2**52.
29: Farintdbig:
30: cmpl #0x7ff00000,d2
31: blts Farintddone | Branch if x is finite.
32: bgts 1f | Branch if x is nan.
33: tstl d1
34: beqs Farintddone | Branch if x is infinity.
35: 1:
36: bset #19,d0 | Convert quiet to signalling.
37: bras Farintddone
38: 3:
39: roll #8,d2
40: roll #4,d2
41: andw #0xfff,d2 | d2 gets biased exponent.
42: cmpw #0x3ff+20,d2
43: bges 4f | Branch if exp >= 20.
44: subw #0x3ff+19,d2 | d2 gets unbiased exponent - 19.
45: negw d2 | d2 gets 19-exp = bit number.
46: clrl d3
47: bset d2,d3 | Set round bit.
48: addl d3,d0 | Add round bit.
49: lsll #1,d3 | Make 2**0 bit.
50: subql #1,d3 | Fraction bit mask.
51: tstl d1
52: bnes 2f | Branch if not ambiguous case.
53: movel d0,d4
54: andl d3,d4 | d4 gets rounded fraction field.
55: bnes 2f | Branch if not ambiguous case.
56: addqw #1,d2 | Make bit number for 2**0.
57: bclr d2,d0 | Force round to even.
58: 2:
59: notl d3
60: andl d3,d0 | Clear fraction field.
61: 1:
62: clrl d1 | Lower half is all fraction bits.
63: bras Farintddone
64: 4:
65: bnes 7f | Branch if exponent > 20.
66: addl #0x80000000,d1 | Add round bit.
67: bccs 8f | Branch if no carry out.
68: addql #1,d0 | Propagate carry.
69: 8:
70: tstl d1
71: bnes 1b | Branch if not ambiguous.
72: bclr #0,d0 | Force round to even.
73: bras Farintddone
74: 7:
75: subw #0x3ff+51,d2 | d2 gets exp-51.
76: negw d2 | d2 gets bit number 51-exp.
77: clrl d3
78: bset d2,d3 | Set round bit.
79: addl d3,d1 | Add round.
80: bccs 9f
81: addql #1,d0 | Propagate carry.
82: 9:
83: movel d3,d4
84: subql #1,d4
85: orl d4,d3 | d3 gets fraction bit mask.
86: movel d3,d4
87: andl d1,d4
88: bnes 1f | Branch if not ambiguous.
89: addqw #1,d2
90: bclr d2,d1 | Force round to even.
91: 1:
92: notl d3
93: andl d3,d1 | Clear fraction bits.
94: Farintddone:
95: moveml sp@+,d2-d4
96: RET
97:
98: RTENTRY(Fanintd)
99: moveml d2-d4,sp@-
100: movel d0,d2 | d2 gets top(x).
101: bclr #31,d2 | d2 gets top(abs(x)).
102: cmpl #0x3ff00000,d2
103: bges 2f | Branch if abs(x) >= 1.0.
104: andl #0x80000000,d0 | Isolate sign of x.
105: cmpl #0x3fe00000,d2
106: blts 6f | Branch if abs(x) < 0.5.
107: orl #0x3ff00000,d0 | Make signed 1.0.
108: 6:
109: clrl d1 | Clear lower part in any case.
110: jra Farintddone
111: 2:
112: cmpl #0x43300000,d2
113: jge Farintdbig | Branch if not 1 <= |x| < 2**52.
114: roll #8,d2
115: roll #4,d2
116: andw #0xfff,d2 | d2 gets biased exponent.
117: cmpw #0x3ff+20,d2
118: bges 4f | Branch if exp >= 20.
119: subw #0x3ff+19,d2 | d2 gets unbiased exponent - 19.
120: negw d2 | d2 gets 19-exp = bit number.
121: clrl d3
122: bset d2,d3 | Set round bit.
123: addl d3,d0 | Add round bit.
124: lsll #1,d3 | Make 2**0 bit.
125: subql #1,d3 | Fraction bit mask.
126: notl d3
127: andl d3,d0 | Clear fraction field.
128: 1:
129: clrl d1 | Lower half is all fraction bits.
130: bras Farintddone
131: 4:
132: bnes 7f | Branch if exponent > 20.
133: addl #0x80000000,d1 | Add round bit.
134: bccs 1b | Branch if no carry out.
135: addql #1,d0 | Propagate carry.
136: bras 1b
137: 7:
138: subw #0x3ff+51,d2 | d2 gets exp-51.
139: negw d2 | d2 gets bit number 51-exp.
140: clrl d3
141: bset d2,d3 | Set round bit.
142: addl d3,d1 | Add round.
143: bccs 9f
144: addql #1,d0 | Propagate carry.
145: 9:
146: lsll #1,d3
147: subql #1,d3
148: notl d3
149: andl d3,d1 | Clear fraction bits.
150: jra Farintddone
151:
152: RTENTRY(Faintd)
153: moveml d2-d4,sp@-
154: movel d0,d2 | d2 gets top(x).
155: bclr #31,d2 | d2 gets top(abs(x)).
156: cmpl #0x3ff00000,d2
157: bges 2f | Branch if abs(x) >= 1.0.
158: andl #0x80000000,d0 | Isolate sign of x.
159: clrl d1 | Clear lower part in any case.
160: jra Farintddone
161: 2:
162: cmpl #0x43300000,d2
163: jge Farintdbig | Branch if not 1 <= |x| < 2**52.
164: roll #8,d2
165: roll #4,d2
166: andw #0xfff,d2 | d2 gets biased exponent.
167: cmpw #0x3ff+20,d2
168: bges 4f | Branch if exp >= 20.
169: subw #0x3ff+20,d2 | d2 gets unbiased exponent - 20.
170: negw d2 | d2 gets 20-exp = bit number.
171: clrl d3
172: bset d2,d3 | Set round bit.
173: subql #1,d3 | Fraction bit mask.
174: notl d3
175: andl d3,d0 | Clear fraction field.
176: 1:
177: clrl d1 | Lower half is all fraction bits.
178: jra Farintddone
179: 4:
180: beqs 1b | Branch if exponent not > 20.
181: 7:
182: subw #0x3ff+52,d2 | d2 gets exp-52.
183: negw d2 | d2 gets bit number 52-exp.
184: clrl d3
185: bset d2,d3 | Set round bit.
186: subql #1,d3
187: notl d3
188: andl d3,d1 | Clear fraction bits.
189: jra Farintddone
190:
191: RTENTRY(Ffloord)
192: moveml d0-d3,sp@- | Save x and d2/d3.
193: jbsr Faintd | d0 gets aint(x).
194: moveml sp@+,d2-d3 | d2/d3 gets x.
195: tstl d2
196: bpls Ffloorddone | Branch if x is positive.
197: cmpl d0,d2
198: bnes 1f
199: cmpl d1,d3
200: beqs Ffloorddone | Return x if x = aint(x).
201: 1:
202: lea one,a0
203: jsr Fsubd | d0 gets aint(x)-1.
204: Ffloorddone:
205: moveml sp@+,d2-d3
206: RET
207:
208: one: .double 0r1.0
209:
210: RTENTRY(Fceild)
211: moveml d0-d3,sp@- | Save x and d2/d3.
212: jbsr Faintd | d0 gets aint(x).
213: moveml sp@+,d2-d3 | d2/d3 gets x.
214: tstl d2
215: bmis Fceilddone | Branch if x is negative.
216: cmpl d0,d2
217: bnes 1f
218: cmpl d1,d3
219: beqs Fceilddone | Return x if x = aint(x).
220: 1:
221: lea one,a0
222: jsr Faddd | d0 gets aint(x)+1.
223: Fceilddone:
224: moveml sp@+,d2-d3
225: RET
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.