Commit | Line | Data |
---|---|---|
7780eb5e KB |
1 | /*- |
2 | * Copyright (c) 1991 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This code is derived from software contributed to Berkeley by | |
6 | * Ralph Campbell. | |
7 | * | |
8 | * %sccs.include.redist.c% | |
9 | */ | |
10 | ||
073522ce | 11 | #include <machine/machAsmDefs.h> |
f1e99c02 | 12 | |
7780eb5e | 13 | #if defined(LIBC_SCCS) && !defined(lint) |
073522ce | 14 | ASMSTR("@(#)modf.s 5.4 (Berkeley) %G%") |
7780eb5e KB |
15 | #endif /* LIBC_SCCS and not lint */ |
16 | ||
7780eb5e KB |
17 | /* |
18 | * double modf(val, iptr) | |
19 | * double val, *iptr; | |
20 | * returns: xxx and n (in *iptr) where val == n.xxx | |
21 | */ | |
22 | LEAF(modf) | |
528228db RC |
23 | cfc1 t0, $31 # get the control register |
24 | cfc1 t0, $31 # get the control register | |
25 | or t1, t0, 0x3 # set rounding mode to round to zero | |
26 | xor t1, t1, 0x2 # (i.e., 01) | |
27 | ctc1 t1, $31 | |
28 | cvt.w.d $f0, $f12 # convert val to integer | |
29 | cvt.d.w $f0, $f0 # convert back to double | |
30 | ctc1 t0, $31 # restore old rounding mode | |
31 | s.d $f0, 0(a2) # save the integer part | |
32 | sub.d $f0, $f12, $f0 # subtract val - integer part | |
7780eb5e KB |
33 | j ra |
34 | END(modf) |