1231855Sbz/* 2231855Sbz * Written by J.T. Conklin <jtc@NetBSD.org>. 3281974Sngie * Public domain. 4281974Sngie */ 5231855Sbz 6276486Sngie#include <machine/asm.h> 7231855Sbz 8231855Sbz#include "abi.h" 9281974Sngie 10281974Sngie 11281974SngieRCSID("$NetBSD: e_expf.S,v 1.5 2003/07/26 19:24:58 salo Exp $") 12281974Sngie 13231855Sbz/* e^x = 2^(x * log2(e)) */ 14231855SbzENTRY(__ieee754_expf) 15231855Sbz XMM_ONE_ARG_FLOAT_PROLOGUE 16231855Sbz 17 /* 18 * catch +/-Inf and NaN arguments 19 */ 20 movl ARG_FLOAT_ONE,%eax 21 andl $0x7fffffff,%eax 22 cmpl $0x7f800000,%eax 23 jae x_Inf_or_NaN 24 25 flds ARG_FLOAT_ONE 26 fldl2e 27 fmulp /* x * log2(e) */ 28 fld %st(0) 29 frndint /* int(x * log2(e)) */ 30 fsubr %st(0),%st(1) /* fract(x * log2(e)) */ 31 fxch 32 f2xm1 /* 2^(fract(x * log2(e))) - 1 */ 33 fld1 34 faddp /* 2^(fract(x * log2(e))) */ 35 fscale /* e^x */ 36 fstp %st(1) 37 XMM_FLOAT_EPILOGUE 38 ret 39 40x_Inf_or_NaN: 41 /* 42 * Return 0 if x is -Inf. Otherwise just return x, although the 43 * C version would return (x + x) (Real Indefinite) if x is a NaN. 44 */ 45 movl ARG_FLOAT_ONE,%eax 46 cmpl $0xff800000,%eax 47 jne x_not_minus_Inf 48 fldz 49 XMM_FLOAT_EPILOGUE 50 ret 51 52x_not_minus_Inf: 53 flds ARG_FLOAT_ONE 54 XMM_FLOAT_EPILOGUE 55 ret 56