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