152707Sbostic/*- 252707Sbostic * Copyright (c) 1991 The Regents of the University of California. 352707Sbostic * All rights reserved. 452707Sbostic * 552707Sbostic * This code is derived from software contributed to Berkeley by 652707Sbostic * Ralph Campbell. 752707Sbostic * 852707Sbostic * %sccs.include.redist.c% 952707Sbostic */ 1052707Sbostic 1152739Sbostic#include "DEFS.h" 1252739Sbostic 1352707Sbostic#if defined(LIBC_SCCS) && !defined(lint) 14*52962Sralph ASMSTR("@(#)modf.s 5.3 (Berkeley) 03/15/92") 1552707Sbostic#endif /* LIBC_SCCS and not lint */ 1652707Sbostic 1752707Sbostic/* 1852707Sbostic * double modf(val, iptr) 1952707Sbostic * double val, *iptr; 2052707Sbostic * returns: xxx and n (in *iptr) where val == n.xxx 2152707Sbostic */ 2252707SbosticLEAF(modf) 23*52962Sralph cfc1 t0, $31 # get the control register 24*52962Sralph cfc1 t0, $31 # get the control register 25*52962Sralph or t1, t0, 0x3 # set rounding mode to round to zero 26*52962Sralph xor t1, t1, 0x2 # (i.e., 01) 27*52962Sralph ctc1 t1, $31 28*52962Sralph cvt.w.d $f0, $f12 # convert val to integer 29*52962Sralph cvt.d.w $f0, $f0 # convert back to double 30*52962Sralph ctc1 t0, $31 # restore old rounding mode 31*52962Sralph s.d $f0, 0(a2) # save the integer part 32*52962Sralph sub.d $f0, $f12, $f0 # subtract val - integer part 3352707Sbostic j ra 3452707SbosticEND(modf) 35