aboutsummaryrefslogtreecommitdiffstats
path: root/testfloat/386-Win32-gcc/systfloat.S
blob: 01e8983e4945dff1f09f6586e335ef1406e01b85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332

/*
===============================================================================

This GNU assembler source file is part of TestFloat, Release 2a, a package
of programs for testing the correctness of floating-point arithmetic
complying to the IEC/IEEE Standard for Floating-Point.

Written by John R. Hauser.  More information is available through the Web
page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.

THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.

Derivative works are acceptable, even for commercial purposes, so long as
(1) they include prominent notice that the work is derivative, and (2) they
include prominent notice akin to these four paragraphs for those parts of
this code that are retained.

===============================================================================
*/

	.text

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_int32_to_floatx80
_syst_int32_to_floatx80:
	fildl 8(%esp)
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_int64_to_floatx80
_syst_int64_to_floatx80:
	fildq 8(%esp)
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_float32_to_floatx80
_syst_float32_to_floatx80:
	flds 8(%esp)
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_float64_to_floatx80
_syst_float64_to_floatx80:
	fldl 8(%esp)
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_to_int32
_syst_floatx80_to_int32:
	fldt 4(%esp)
	subl $4,%esp
	fistpl (%esp)
	movl (%esp),%eax
	addl $4,%esp
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_to_int64
_syst_floatx80_to_int64:
	fldt 4(%esp)
	subl $8,%esp
	fistpq (%esp)
	movl (%esp),%eax
	movl 4(%esp),%edx
	addl $8,%esp
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_to_float32
_syst_floatx80_to_float32:
	fldt 4(%esp)
	subl $4,%esp
	fstps (%esp)
	movl (%esp),%eax
	addl $4,%esp
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_to_float64
_syst_floatx80_to_float64:
	fldt 4(%esp)
	subl $8,%esp
	fstpl (%esp)
	movl 4(%esp),%edx
	movl (%esp),%eax
	addl $8,%esp
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_round_to_int
_syst_floatx80_round_to_int:
	fldt 8(%esp)
	frndint
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_add
_syst_floatx80_add:
	fldt 8(%esp)
	fldt 20(%esp)
	faddp
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_sub
_syst_floatx80_sub:
	fldt 8(%esp)
	fldt 20(%esp)
	fsubrp
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_mul
_syst_floatx80_mul:
	fldt 8(%esp)
	fldt 20(%esp)
	fmulp
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_div
_syst_floatx80_div:
	fldt 8(%esp)
	fldt 20(%esp)
	fdivrp
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_rem
_syst_floatx80_rem:
	fldt 20(%esp)
	fldt 8(%esp)
floatx80_rem_loop:
	fprem1
	fnstsw %ax
	btw $10,%ax
	jc floatx80_rem_loop
	movl 4(%esp),%eax
	fstpt (%eax)
	fstp %st(0)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_sqrt
_syst_floatx80_sqrt:
	fldt 8(%esp)
	fsqrt
	movl 4(%esp),%eax
	fstpt (%eax)
	ret $4

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_eq
_syst_floatx80_eq:
	fldt 16(%esp)
	fldt 4(%esp)
	fucompp
	fnstsw %ax
	andw $17664,%ax
	cmpw $16384,%ax
	seteb %al
	movzb %al,%eax
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_le
_syst_floatx80_le:
	fldt 4(%esp)
	fldt 16(%esp)
	fcompp
	fnstsw %ax
	notl %eax
	shrl $8,%eax
	andl $1,%eax
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_lt
_syst_floatx80_lt:
	fldt 4(%esp)
	fldt 16(%esp)
	fcompp
	fnstsw %ax
	andw $17664,%ax
	setzb %al
	movzb %al,%eax
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_eq_signaling
_syst_floatx80_eq_signaling:
	fldt 16(%esp)
	fldt 4(%esp)
	fcompp
	fnstsw %ax
	andw $17664,%ax
	cmpw $16384,%ax
	seteb %al
	movzb %al,%eax
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_le_quiet
_syst_floatx80_le_quiet:
	fldt 4(%esp)
	fldt 16(%esp)
	fucompp
	fnstsw %ax
	notl %eax
	shrl $8,%eax
	andl $1,%eax
	ret

/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
	.align 2
.globl _syst_floatx80_lt_quiet
_syst_floatx80_lt_quiet:
	fldt 4(%esp)
	fldt 16(%esp)
	fucompp
	fnstsw %ax
	andw $17664,%ax
	setzb %al
	movzb %al,%eax
	ret