Commit | Line | Data |
---|---|---|
91073d83 | 1 | /*- |
b17c65bb KB |
2 | * Copyright (c) 1990, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
91073d83 WN |
4 | * |
5 | * This code is derived from software contributed to Berkeley by | |
2604023d | 6 | * Sean Eric Fagan. |
91073d83 WN |
7 | * |
8 | * %sccs.include.redist.c% | |
9 | */ | |
10 | ||
11 | #if defined(LIBC_SCCS) && !defined(lint) | |
b17c65bb | 12 | .asciz "@(#)modf.s 8.1 (Berkeley) %G%" |
91073d83 WN |
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. */ | |
dba34523 WN |
24 | .text |
25 | .globl _modf | |
26 | _modf: | |
27 | pushl %ebp | |
28 | movl %esp,%ebp | |
29 | subl $16,%esp | |
dba34523 | 30 | fnstcw -12(%ebp) |
dba34523 WN |
31 | movw -12(%ebp),%dx |
32 | orw $3072,%dx | |
33 | movw %dx,-16(%ebp) | |
dba34523 | 34 | fldcw -16(%ebp) |
dba34523 | 35 | fldl 8(%ebp) |
dba34523 | 36 | frndint |
dba34523 | 37 | fstpl -8(%ebp) |
dba34523 | 38 | fldcw -12(%ebp) |
dba34523 WN |
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 | |
47 | L1: | |
48 | leave | |
49 | ret |