xref: /csrg-svn/lib/libc/i386/gen/modf.s (revision 45821)
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * 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.c	5.1 (Berkeley) 4/23/90"
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/APP
31	fnstcw -12(%ebp)
32/NO_APP
33	movw -12(%ebp),%dx
34	orw $3072,%dx
35	movw %dx,-16(%ebp)
36/APP
37	fldcw -16(%ebp)
38/NO_APP
39	fldl 8(%ebp)
40/APP
41	frndint
42/NO_APP
43	fstpl -8(%ebp)
44/APP
45	fldcw -12(%ebp)
46/NO_APP
47	movl 16(%ebp),%eax
48	movl -8(%ebp),%edx
49	movl -4(%ebp),%ecx
50	movl %edx,(%eax)
51	movl %ecx,4(%eax)
52	fldl 8(%ebp)
53	fsubl -8(%ebp)
54	jmp L1
55L1:
56	leave
57	ret
58