File: frexp.S

package info (click to toggle)
libc-sparc 5.3.12-3
  • links: PTS
  • area: main
  • in suites: potato, slink
  • size: 17,608 kB
  • ctags: 44,718
  • sloc: ansic: 163,548; asm: 5,080; makefile: 3,340; lex: 521; sh: 439; yacc: 401; awk: 28
file content (313 lines) | stat: -rw-r--r-- 4,438 bytes parent folder | download | duplicates (14)
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
	.file "frexp.S"

#ifdef __ELF__
#define _frexp	frexp
#define _ldexp	ldexp
#ifdef __i486__
#define ALIGN_TEXT	16,0x90
#else
#define ALIGN_TEXT	4,0x90
#endif
#define ALIGN_DATA	4
#else
#ifdef __i486__
#define ALIGN_TEXT	4,0x90
#else
#define ALIGN_TEXT	2,0x90
#endif
#define ALIGN_DATA	2
#endif

#ifdef __ELF__
	.section	.rodata
#else
	.text
#endif

	.align ALIGN_TEXT

#ifdef __ELF__
.LC0:
#else
LC0:
#endif
	.double	1.7976931348623157e+308

	.align ALIGN_TEXT

#ifdef __ELF__
.LC1:
#else
LC1:
#endif
	.long	0x0,0x40000000

	.text
	.globl _frexp

	.align ALIGN_TEXT
_frexp:
	pushl	%ebp
	movl	%esp,%ebp
	subl	$16,%esp
	pushl	%esi
	pushl	%ebx
/* y = x; */
	fldl	8(%ebp)
	movl	16(%ebp),%ebx
	fstl	-8(%ebp)
/* q = (short *)&y + 3; */
	leal	-2(%ebp),%ecx
/* i  = ( *q >> 4) & 0x7ff; */
	movw	-2(%ebp),%ax
	sarw	$4,%ax
	movl	%eax,%edx
	andl	$2047,%edx
/* if( i != 0 )       */
/*	goto ieeedon; */
	jne	L22
/* if( y == 0.0 ) */
	fldz
	fucompp
	fnstsw	%ax
	andb	$68,%ah
	xorb	$64,%ah
	jne	L18
/* *pw2 = 0; */
	movl	$0,(%ebx)
/* return( 0.0 ); */
	fldz
	jmp	L21
	.align	ALIGN_DATA,0x90
/* do { */
L18:
/* y *= 2.0; */
	fldl	-8(%ebp)
	fadd	%st(0),%st
	fstpl	-8(%ebp)
/* i -= 1; */
	decl	%edx
/* k  = ( *q >> 4) & 0x7ff; */
	movw	(%ecx),%ax
	sarw	$4,%ax
	movl	%eax,%esi
	andl	$2047,%esi
/* while( k == 0 ); */
	je	L18
/* i = i + k; */
	addl	%esi,%edx
	jmp	L16
	.align	ALIGN_DATA,0x90
/* ieeedon: */
L22:
	fstp	%st(0)
L16:
/* i -= 0x3fe; */
	addl	$-1022,%edx
/* *pw2 = i; */
	movl	%edx,(%ebx)
/* *q &= 0x800f; */
	andw	$32783,(%ecx)
/* *q |= 0x3fe0; */
	orw	$16352,(%ecx)
/* return( y ); */
	fldl	-8(%ebp)
L21:
	leal	-24(%ebp),%esp
	popl	%ebx
	popl	%esi
	leave
	ret

	.globl	_ldexp
	.align ALIGN_TEXT
_ldexp:
	pushl	%ebp
	movl	%esp,%ebp
	subl	$20,%esp
	pushl	%esi
	pushl	%ebx
/* power of 2 */
	movl	16(%ebp),%esi
/* y = x */
	movl	8(%ebp),%eax
	movl	12(%ebp),%edx
	movl	%eax,-8(%ebp)
	movl	%edx,-4(%ebp)
/* q = (short *)&y + 3; */
	leal	-2(%ebp),%ecx
/* while( (e = (*q & 0x7ff0) >> 4) == 0 ) { */
	movw	-2(%ebp),%dx
	andw	$32752,%dx
	sarw	$4,%dx
	movswl	%dx,%ebx
	testl	%ebx,%ebx
	jne	L25
	fldz
#ifdef __PIC__
	pushl	%ebx
	call	.L2
.L2:
	popl	%ebx
	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L2],%ebx
	fldl	.LC1@GOTOFF(%ebx)
	popl	%ebx
#else
#ifdef __ELF__
	fldl	.LC1
#else
	fldl	LC1
#endif
#endif
	.align	ALIGN_DATA,0x90
L31:
/* if( y == 0.0 )  return( 0.0 ); */
	fldl	-8(%ebp)
	fucom	%st(2)
	fnstsw	%ax
	andb	$69,%ah
	cmpb	$64,%ah
	je	L45
/* if( pw2 > 0 ) { */
	testl	%esi,%esi
	jle	L46
/* y *= 2.0; */
	fadd	%st(0),%st
	fstpl	-8(%ebp)
/* pw2 -= 1; */
	decl	%esi
	jmp	L27
	.align	ALIGN_DATA,0x90
L46:
	fstp	%st(0)
L27:
/* if( pw2 < 0 ) { */
	testl	%esi,%esi
	jge	L28
/* if( pw2 < -53 )  return(0.0); */
	cmpl	$-53,%esi
	jl	L47
/* y /= 2.0; */
	fld	%st(0)
	fdivrl	-8(%ebp)
	fstpl	-8(%ebp)
/* pw2 += 1; */
	incl	%esi
L28:
/* if( pw2 == 0 ) return(y); */
	testl	%esi,%esi
	je	L48
/* } while exponent is zero */
	movw	(%ecx),%ax
	andw	$32752,%ax
	sarw	$4,%ax
	movswl	%ax,%ebx
	testl	%ebx,%ebx
	je	L31
	fstp	%st(0)
	fstp	%st(0)
L25:
/* e += pw2; */
	addl	%esi,%ebx
/* if( e > MEXP )  return( MAXNUM ); */
	cmpl	$2047,%ebx
	jle	L32
#ifdef __PIC__
	pushl	%ebx
	call	.L3
.L3:
	popl	%ebx
	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L3],%ebx
	fldl	.LC0@GOTOFF(%ebx)
	popl	%ebx
#else
#ifdef __ELF__
	fldl	.LC0
#else
	fldl	LC0
#endif
#endif
	jmp	L39
	.align	ALIGN_DATA,0x90
L32:
/* if( e < 1 ) */
	testl	%ebx,%ebx
	jg	L33
/* if( e < -53 ) return(0.0); */
	cmpl	$-53,%ebx
	jge	L34
	jmp	L44
	.align	ALIGN_DATA,0x90
L45:
	fstp	%st(0)
L47:
	fstp	%st(0)
	fstp	%st(0)
L44:
	fldz
	jmp	L39
	.align	ALIGN_DATA,0x90
L34:
/* *q &= 0x800f; */
	andw	$32783,(%ecx)
/* *q |= 0x10; */
	orb	$16,(%ecx)
/* while( e < 1 ) */
	testl	%ebx,%ebx
	jg	L43
#ifdef __PIC__
	pushl	%ebx
	call	.L4
.L4:
	popl	%ebx
	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L4],%ebx
	fldl	.LC1@GOTOFF(%ebx)
	popl	%ebx
#else
#ifdef __ELF__
	fldl	.LC1
#else
	fldl	LC1
#endif
#endif
	.align	ALIGN_DATA,0x90
L37:
/* y /= 2.0; */
	fld	%st(0)
	fdivrl	-8(%ebp)
	fstpl	-8(%ebp)
/* e += 1; */
	incl	%ebx
	testl	%ebx,%ebx
	jle	L37
/* return(y); */
	jmp	L49
	.align	ALIGN_DATA,0x90
L33:
/* *q &= 0x800f; */
	andw	$32783,(%ecx)
/* *q |= (e & 0x7ff) << 4; */
	movl	%ebx,%eax
	andb	$7,%ah
	salw	$4,%ax
	orw	%ax,(%ecx)
	jmp	L43
	.align	ALIGN_DATA,0x90
L48:
	fstp	%st(0)
L49:
	fstp	%st(0)
L43:
/* return(y); */
	fldl	-8(%ebp)
L39:
	leal	-28(%ebp),%esp
	popl	%ebx
	popl	%esi
	leave
	ret

#ifdef __ELF__
	.type	frexp,@function
	.type	ldexp,@function
#endif