1/* 2 * Written by J.T. Conklin <jtc@netbsd.org>. 3 * Public domain. 4 * 5 * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>. 6 */ 7 8#include <machine/asm.h> 9 10RCSID("$NetBSD: e_log10.S,v 1.4 1995/05/08 23:49:24 jtc Exp $") 11 12#ifdef __ELF__ 13 .section .rodata 14#else 15 .text 16#endif 17 .align ALIGNARG(4) 18 ASM_TYPE_DIRECTIVE(one,@object) 19one: .double 1.0 20 ASM_SIZE_DIRECTIVE(one) 21 /* It is not important that this constant is precise. It is only 22 a value which is known to be on the safe side for using the 23 fyl2xp1 instruction. */ 24 ASM_TYPE_DIRECTIVE(limit,@object) 25limit: .double 0.29 26 ASM_SIZE_DIRECTIVE(limit) 27 28 29#ifdef PIC 30#define MO(op) op##@GOTOFF(%edx) 31#else 32#define MO(op) op 33#endif 34 35 .text 36ENTRY(__ieee754_log10) 37 fldlg2 // log10(2) 38 fldl 4(%esp) // x : log10(2) 39#ifdef PIC 40 call 1f 411: popl %edx 42 addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx 43#endif 44 fxam 45 fnstsw 46 fld %st // x : x : log10(2) 47 sahf 48 jc 3f // in case x is NaN or �Inf 494: fsubl MO(one) // x-1 : x : log10(2) 50 fld %st // x-1 : x-1 : x : log10(2) 51 fabs // |x-1| : x-1 : x : log10(2) 52 fcompl MO(limit) // x-1 : x : log10(2) 53 fnstsw // x-1 : x : log10(2) 54 andb $0x45, %ah 55 jz 2f 56 fstp %st(1) // x-1 : log10(2) 57 fyl2xp1 // log10(x) 58 ret 59 602: fstp %st(0) // x : log10(2) 61 fyl2x // log10(x) 62 ret 63 643: jp 4b // in case x is �Inf 65 fstp %st(1) 66 fstp %st(1) 67 ret 68END (__ieee754_log10) 69