xref: /original-bsd/lib/libc/i386/gen/fixunsdfsi.s (revision 36940495)
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
12	.asciz "@(#)fixunsdfsi.s	8.1	06/04/93"
13#endif /* LIBC_SCCS and not lint */
14
15	.globl ___fixunsdfsi
16___fixunsdfsi:
17	fldl	4(%esp)		/* argument double to accum stack */
18	frndint			/* create integer */
19	fcoml	fbiggestsigned	/* bigger than biggest signed? */
20	fstsw	%ax
21	sahf
22	jnb	1f
23
24	fistpl	4(%esp)
25	movl	4(%esp),%eax
26	ret
27
281:	fsubl	fbiggestsigned	/* reduce for proper conversion */
29	fistpl	4(%esp)		/* convert */
30	movl	4(%esp),%eax
31	orl	$0x80000000,%eax	/* restore bias */
32	ret
33
34fbiggestsigned:	.double	0r2147483648.0
35