systfloat.S revision 1.1 1
2 /*
3 ===============================================================================
4
5 This GNU assembler source file is part of TestFloat, Release 2a, a package
6 of programs for testing the correctness of floating-point arithmetic
7 complying to the IEC/IEEE Standard for Floating-Point.
8
9 Written by John R. Hauser. More information is available through the Web
10 page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
11
12 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
13 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
14 TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
15 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
16 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
17
18 Derivative works are acceptable, even for commercial purposes, so long as
19 (1) they include prominent notice that the work is derivative, and (2) they
20 include prominent notice akin to these four paragraphs for those parts of
21 this code that are retained.
22
23 ===============================================================================
24 */
25
26 .text
27
28 /*
29 -------------------------------------------------------------------------------
30 -------------------------------------------------------------------------------
31 */
32 .align 2
33 .globl _syst_int32_to_floatx80
34 _syst_int32_to_floatx80:
35 fildl 8(%esp)
36 movl 4(%esp),%eax
37 fstpt (%eax)
38 ret $4
39
40 /*
41 -------------------------------------------------------------------------------
42 -------------------------------------------------------------------------------
43 */
44 .align 2
45 .globl _syst_int64_to_floatx80
46 _syst_int64_to_floatx80:
47 fildq 8(%esp)
48 movl 4(%esp),%eax
49 fstpt (%eax)
50 ret $4
51
52 /*
53 -------------------------------------------------------------------------------
54 -------------------------------------------------------------------------------
55 */
56 .align 2
57 .globl _syst_float32_to_floatx80
58 _syst_float32_to_floatx80:
59 flds 8(%esp)
60 movl 4(%esp),%eax
61 fstpt (%eax)
62 ret $4
63
64 /*
65 -------------------------------------------------------------------------------
66 -------------------------------------------------------------------------------
67 */
68 .align 2
69 .globl _syst_float64_to_floatx80
70 _syst_float64_to_floatx80:
71 fldl 8(%esp)
72 movl 4(%esp),%eax
73 fstpt (%eax)
74 ret $4
75
76 /*
77 -------------------------------------------------------------------------------
78 -------------------------------------------------------------------------------
79 */
80 .align 2
81 .globl _syst_floatx80_to_int32
82 _syst_floatx80_to_int32:
83 fldt 4(%esp)
84 subl $4,%esp
85 fistpl (%esp)
86 movl (%esp),%eax
87 addl $4,%esp
88 ret
89
90 /*
91 -------------------------------------------------------------------------------
92 -------------------------------------------------------------------------------
93 */
94 .align 2
95 .globl _syst_floatx80_to_int64
96 _syst_floatx80_to_int64:
97 fldt 4(%esp)
98 subl $8,%esp
99 fistpq (%esp)
100 movl (%esp),%eax
101 movl 4(%esp),%edx
102 addl $8,%esp
103 ret
104
105 /*
106 -------------------------------------------------------------------------------
107 -------------------------------------------------------------------------------
108 */
109 .align 2
110 .globl _syst_floatx80_to_float32
111 _syst_floatx80_to_float32:
112 fldt 4(%esp)
113 subl $4,%esp
114 fstps (%esp)
115 movl (%esp),%eax
116 addl $4,%esp
117 ret
118
119 /*
120 -------------------------------------------------------------------------------
121 -------------------------------------------------------------------------------
122 */
123 .align 2
124 .globl _syst_floatx80_to_float64
125 _syst_floatx80_to_float64:
126 fldt 4(%esp)
127 subl $8,%esp
128 fstpl (%esp)
129 movl 4(%esp),%edx
130 movl (%esp),%eax
131 addl $8,%esp
132 ret
133
134 /*
135 -------------------------------------------------------------------------------
136 -------------------------------------------------------------------------------
137 */
138 .align 2
139 .globl _syst_floatx80_round_to_int
140 _syst_floatx80_round_to_int:
141 fldt 8(%esp)
142 frndint
143 movl 4(%esp),%eax
144 fstpt (%eax)
145 ret $4
146
147 /*
148 -------------------------------------------------------------------------------
149 -------------------------------------------------------------------------------
150 */
151 .align 2
152 .globl _syst_floatx80_add
153 _syst_floatx80_add:
154 fldt 8(%esp)
155 fldt 20(%esp)
156 faddp
157 movl 4(%esp),%eax
158 fstpt (%eax)
159 ret $4
160
161 /*
162 -------------------------------------------------------------------------------
163 -------------------------------------------------------------------------------
164 */
165 .align 2
166 .globl _syst_floatx80_sub
167 _syst_floatx80_sub:
168 fldt 8(%esp)
169 fldt 20(%esp)
170 fsubrp
171 movl 4(%esp),%eax
172 fstpt (%eax)
173 ret $4
174
175 /*
176 -------------------------------------------------------------------------------
177 -------------------------------------------------------------------------------
178 */
179 .align 2
180 .globl _syst_floatx80_mul
181 _syst_floatx80_mul:
182 fldt 8(%esp)
183 fldt 20(%esp)
184 fmulp
185 movl 4(%esp),%eax
186 fstpt (%eax)
187 ret $4
188
189 /*
190 -------------------------------------------------------------------------------
191 -------------------------------------------------------------------------------
192 */
193 .align 2
194 .globl _syst_floatx80_div
195 _syst_floatx80_div:
196 fldt 8(%esp)
197 fldt 20(%esp)
198 fdivrp
199 movl 4(%esp),%eax
200 fstpt (%eax)
201 ret $4
202
203 /*
204 -------------------------------------------------------------------------------
205 -------------------------------------------------------------------------------
206 */
207 .align 2
208 .globl _syst_floatx80_rem
209 _syst_floatx80_rem:
210 fldt 20(%esp)
211 fldt 8(%esp)
212 floatx80_rem_loop:
213 fprem1
214 fnstsw %ax
215 btw $10,%ax
216 jc floatx80_rem_loop
217 movl 4(%esp),%eax
218 fstpt (%eax)
219 fstp %st(0)
220 ret $4
221
222 /*
223 -------------------------------------------------------------------------------
224 -------------------------------------------------------------------------------
225 */
226 .align 2
227 .globl _syst_floatx80_sqrt
228 _syst_floatx80_sqrt:
229 fldt 8(%esp)
230 fsqrt
231 movl 4(%esp),%eax
232 fstpt (%eax)
233 ret $4
234
235 /*
236 -------------------------------------------------------------------------------
237 -------------------------------------------------------------------------------
238 */
239 .align 2
240 .globl _syst_floatx80_eq
241 _syst_floatx80_eq:
242 fldt 16(%esp)
243 fldt 4(%esp)
244 fucompp
245 fnstsw %ax
246 andw $17664,%ax
247 cmpw $16384,%ax
248 seteb %al
249 movzb %al,%eax
250 ret
251
252 /*
253 -------------------------------------------------------------------------------
254 -------------------------------------------------------------------------------
255 */
256 .align 2
257 .globl _syst_floatx80_le
258 _syst_floatx80_le:
259 fldt 4(%esp)
260 fldt 16(%esp)
261 fcompp
262 fnstsw %ax
263 notl %eax
264 shrl $8,%eax
265 andl $1,%eax
266 ret
267
268 /*
269 -------------------------------------------------------------------------------
270 -------------------------------------------------------------------------------
271 */
272 .align 2
273 .globl _syst_floatx80_lt
274 _syst_floatx80_lt:
275 fldt 4(%esp)
276 fldt 16(%esp)
277 fcompp
278 fnstsw %ax
279 andw $17664,%ax
280 setzb %al
281 movzb %al,%eax
282 ret
283
284 /*
285 -------------------------------------------------------------------------------
286 -------------------------------------------------------------------------------
287 */
288 .align 2
289 .globl _syst_floatx80_eq_signaling
290 _syst_floatx80_eq_signaling:
291 fldt 16(%esp)
292 fldt 4(%esp)
293 fcompp
294 fnstsw %ax
295 andw $17664,%ax
296 cmpw $16384,%ax
297 seteb %al
298 movzb %al,%eax
299 ret
300
301 /*
302 -------------------------------------------------------------------------------
303 -------------------------------------------------------------------------------
304 */
305 .align 2
306 .globl _syst_floatx80_le_quiet
307 _syst_floatx80_le_quiet:
308 fldt 4(%esp)
309 fldt 16(%esp)
310 fucompp
311 fnstsw %ax
312 notl %eax
313 shrl $8,%eax
314 andl $1,%eax
315 ret
316
317 /*
318 -------------------------------------------------------------------------------
319 -------------------------------------------------------------------------------
320 */
321 .align 2
322 .globl _syst_floatx80_lt_quiet
323 _syst_floatx80_lt_quiet:
324 fldt 4(%esp)
325 fldt 16(%esp)
326 fucompp
327 fnstsw %ax
328 andw $17664,%ax
329 setzb %al
330 movzb %al,%eax
331 ret
332
333