logl.asm revision f1184d89598af5d77617104b80c6cae0fe69f730
208651a016b098f4fa1f6279559f104d70f1632dtakashi; $Id$
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki;; @file
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki; IPRT - No-CRT logl - AMD64 & X86.
0a05fab9aadd37834734ffe106fc8ad4488fb3e3rbowen;
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd;
031b91a62d25106ae69d4693475c79618dd5e884fielding; Copyright (C) 2006-2007 Sun Microsystems, Inc.
031b91a62d25106ae69d4693475c79618dd5e884fielding;
031b91a62d25106ae69d4693475c79618dd5e884fielding; This file is part of VirtualBox Open Source Edition (OSE), as
031b91a62d25106ae69d4693475c79618dd5e884fielding; available from http://www.virtualbox.org. This file is free software;
031b91a62d25106ae69d4693475c79618dd5e884fielding; you can redistribute it and/or modify it under the terms of the GNU
031b91a62d25106ae69d4693475c79618dd5e884fielding; General Public License (GPL) as published by the Free Software
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; Foundation, in version 2 as it comes in the "COPYING" file of the
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd;
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; The contents of this file may alternatively be used under the terms
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; of the Common Development and Distribution License Version 1.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; VirtualBox OSE distribution, in which case the provisions of the
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; CDDL are applicable instead of those of the GPL.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd;
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; You may elect to license modified versions of this file under the
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd; terms and conditions of either the GPL or the CDDL or both.
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki;
208651a016b098f4fa1f6279559f104d70f1632dtakashi; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki; Clara, CA 95054 USA or visit http://www.sun.com if you need
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki; additional information or have any questions.
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki;
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki%include "iprt/asmdefs.mac"
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki
208651a016b098f4fa1f6279559f104d70f1632dtakashiBEGINCODE
208651a016b098f4fa1f6279559f104d70f1632dtakashi
208651a016b098f4fa1f6279559f104d70f1632dtakashi%ifdef RT_ARCH_AMD64
208651a016b098f4fa1f6279559f104d70f1632dtakashi %define _SP rsp
208651a016b098f4fa1f6279559f104d70f1632dtakashi %define _BP rbp
208651a016b098f4fa1f6279559f104d70f1632dtakashi %define _S 8
208651a016b098f4fa1f6279559f104d70f1632dtakashi%else
208651a016b098f4fa1f6279559f104d70f1632dtakashi %define _SP esp
208651a016b098f4fa1f6279559f104d70f1632dtakashi %define _BP ebp
208651a016b098f4fa1f6279559f104d70f1632dtakashi %define _S 4
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki%endif
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki;;
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki; compute the natural logarithm of lrd
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki; @returns st(0)
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki; @param lrd [rbp + _S*2]
208651a016b098f4fa1f6279559f104d70f1632dtakashiBEGINPROC RT_NOCRT(logl)
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki push _BP
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki mov _BP, _SP
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki sub _SP, 10h
208651a016b098f4fa1f6279559f104d70f1632dtakashi
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki fldln2 ; st0=log(2)
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki fld tword [_BP + _S*2] ; st1=log(2) st0=lrd
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki fld st0 ; st1=log(2) st0=lrd st0=lrd
9dca5c120b818e1c51dbbb6c658d95a9f91b524cyoshiki fsub qword [.one xWrtRIP] ; st2=log(2) st1=lrd st0=lrd-1.0
9dca5c120b818e1c51dbbb6c658d95a9f91b524cyoshiki fld st0 ; st3=log(2) st2=lrd st1=lrd-1.0 st0=lrd-1.0
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki fabs ; st3=log(2) st2=lrd st1=lrd-1.0 st0=abs(lrd-1.0)
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki fcomp qword [.limit xWrtRIP] ; st2=log(2) st1=lrd st0=lrd-1.0
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki fnstsw ax
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki and eax, 04500h
208651a016b098f4fa1f6279559f104d70f1632dtakashi jnz .use_st1
208651a016b098f4fa1f6279559f104d70f1632dtakashi
208651a016b098f4fa1f6279559f104d70f1632dtakashi fstp st0 ; st1=log(2) st0=lrd
208651a016b098f4fa1f6279559f104d70f1632dtakashi fyl2x ; log(lrd)
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki jmp .done
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki.use_st1:
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki fstp st1 ; st1=log(2) st0=lrd-1.0
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki fyl2xp1 ; log(lrd)
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki
208651a016b098f4fa1f6279559f104d70f1632dtakashi.done:
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki leave
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki ret
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki.one: dq 1.0
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki.limit: dq 0.29
e50dced6f51b101fcf63e1b51ebf771287870107yoshikiENDPROC RT_NOCRT(logl)
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki
e50dced6f51b101fcf63e1b51ebf771287870107yoshiki