xref: /original-bsd/lib/libc/i386/gen/modf.s (revision c3e32dec)
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 * Sean Eric Fagan.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
12	.asciz "@(#)modf.s	8.1 (Berkeley) 06/04/93"
13#endif /* LIBC_SCCS and not lint */
14
15/*
16 * modf(value, iptr): return fractional part of value, and stores the
17 * integral part into iptr (a pointer to double).
18 *
19 * Written by Sean Eric Fagan (sef@kithrup.COM)
20 * Sun Mar 11 20:27:30 PST 1990
21 */
22
23/* With CHOP mode on, frndint behaves as TRUNC does.  Useful. */
24.text
25.globl _modf
26_modf:
27	pushl %ebp
28	movl %esp,%ebp
29	subl $16,%esp
30	fnstcw -12(%ebp)
31	movw -12(%ebp),%dx
32	orw $3072,%dx
33	movw %dx,-16(%ebp)
34	fldcw -16(%ebp)
35	fldl 8(%ebp)
36	frndint
37	fstpl -8(%ebp)
38	fldcw -12(%ebp)
39	movl 16(%ebp),%eax
40	movl -8(%ebp),%edx
41	movl -4(%ebp),%ecx
42	movl %edx,(%eax)
43	movl %ecx,4(%eax)
44	fldl 8(%ebp)
45	fsubl -8(%ebp)
46	jmp L1
47L1:
48	leave
49	ret
50