2 * Copyright (c) 1992 Helsinki University of Technology
5 * Permission to use, copy, modify and distribute this software and its
6 * documentation is hereby granted, provided that both the copyright
7 * notice and this permission notice appear in all copies of the
8 * software, derivative works or modified versions, and any portions
9 * thereof, and that both notices appear in supporting documentation.
11 * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN
12 * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY
13 * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
14 * USE OF THIS SOFTWARE.
18 * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology
21 * $Id: frexp.s,v 1.1 1993/09/17 18:43:46 phil Exp $
25 double frexp(value, eptr)
29 The frexp subroutine returns the mantissa of a double value
30 as a double quantity, x, of magnitude less than one and
31 greater than or equal to 0.5 (0.5 <= |x| < 1) and stores an
32 integer n such that value = x*2**n indirectly through eptr.
34 One exception: if the given value is 0, then x and *eptr are made
38 #include <machine/asm.h>
42 movd
12(fp
),r1 /* value, high 32 bit */
43 cmpd 0,r1 /* check if 0 */
44 beq frexp_zero
/* we do not support denormalized values */
46 bicd
0x7ff00000,r2 /* clear exponent */
47 ord
0x3fe00000,r2 /* set it to 1024 == exponent -11 == .5-1 */
48 lshd
-20,r1 /* extract exponent */
49 andd
0x7ff,r1 /* 11 lower bits */
50 subd
1022,r1 /* unbias exponent */
52 movd
8(fp
),-8(fp
) /* value, low 32 bit */
53 movd
r2,-4(fp
) /* value without exponent, high 32 bit */
54 movl
-8(fp
),f0 /* load return value */
58 movqd
0,0(16(fp
)) /* return exp = 0, mantissa = 9 */