Fix mdoc(7)/man(7) mix up.
[netbsd-mini2440.git] / lib / libc / pc532 / gen / frexp.s
blobb727bb0b1b630c126a3cc384dd5f0f60d94ed9a7
1 /*
2 * Copyright (c) 1992 Helsinki University of Technology
3 * All Rights Reserved.
4 *
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.
17 * HISTORY
18 * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology
19 * Created.
21 * $Id: frexp.s,v 1.1 1993/09/17 18:43:46 phil Exp $
25 double frexp(value, eptr)
26 double value;
27 int *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
35 zero.
38 #include <machine/asm.h>
40 ENTRY(frexp)
41 enter [],8
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 */
45 movd r1,r2
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 */
51 movd r1,0(16(fp))
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 */
55 exit []
56 ret 0
57 frexp_zero:
58 movqd 0,0(16(fp)) /* return exp = 0, mantissa = 9 */
59 movdl 0,f0
60 exit []
61 ret 0