comparison src/build-msvctools/math/log2.S @ 3061:f8299bb6c872

Initial support for native MSVC compilation. * add MSVC support files: compiler wrappers and support libraries * adapt libiconv to work with MSVC * adapt gettext to work with MSVC
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 17 Jun 2013 22:43:11 -0400
parents
children
comparison
equal deleted inserted replaced
3060:cbdf4575016d 3061:f8299bb6c872
1 /*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Adapted for use as log2 by Ulrich Drepper <drepper@cygnus.com>.
4 * Public domain.
5 *
6 * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
7 *
8 * Removed header file dependency for use in libmingwex.a by
9 * Danny Smith <dannysmith@users.sourceforge.net>
10 */
11
12 .file "log2.S"
13 .text
14 .align 4
15 one: .double 1.0
16 /* It is not important that this constant is precise. It is only
17 a value which is known to be on the safe side for using the
18 fyl2xp1 instruction. */
19 limit: .double 0.29
20
21 .text
22 .align 4
23 .globl _log2
24 .def _log2; .scl 2; .type 32; .endef
25 _log2:
26 fldl one
27 fldl 4(%esp) /* x : 1 */
28 fxam
29 fnstsw
30 fld %st /* x : x : 1 */
31 sahf
32 jc 3f /* in case x is NaN or ħInf */
33 4: fsub %st(2), %st /* x-1 : x : 1 */
34 fld %st /* x-1 : x-1 : x : 1 */
35 fabs /* |x-1| : x-1 : x : 1 */
36 fcompl limit /* x-1 : x : 1 */
37 fnstsw /* x-1 : x : 1 */
38 andb $0x45, %ah
39 jz 2f
40 fstp %st(1) /* x-1 : 1 */
41 fyl2xp1 /* log(x) */
42 ret
43
44 2: fstp %st(0) /* x : 1 */
45 fyl2x /* log(x) */
46 ret
47
48 3: jp 4b /* in case x is ħInf */
49 fstp %st(1)
50 fstp %st(1)
51 ret