VirtualBox

忽略:
時間撮記:
2022-8-17 上午01:59:06 (3 年 以前)
作者:
vboxsync
svn:sync-xref-src-repo-rev:
153054
訊息:

IPRT/nocrt: Adapted the reworked sin and cos code for sinf and cosf; fixed a few cos bugs and added tests for cos. bugref:10261

檔案:
複製 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/common/math/cosf.asm

    r96240 r96242  
    11; $Id$
    22;; @file
    3 ; IPRT - No-CRT cos - AMD64 & X86.
     3; IPRT - No-CRT cosf - AMD64 & X86.
    44;
    55
     
    3434
    3535;;
    36 ; Compute the cosine of rd, measured in radians.
     36; Compute the cosine of rf, measured in radians.
    3737;
    3838; @returns  st(0) / xmm0
    39 ; @param    rd      [rbp + xCB*2] / xmm0
    40 ;
    41 RT_NOCRT_BEGINPROC cos
     39; @param    rf      [rbp + xCB*2] / xmm0
     40;
     41RT_NOCRT_BEGINPROC cosf
    4242        push    xBP
    4343        SEH64_PUSH_xBP
     
    6464        ;
    6565%ifdef RT_ARCH_AMD64
    66         movsd   [xBP - 10h], xmm0
    67         fld     qword [xBP - 10h]
     66        movss   [xBP - 10h], xmm0
     67        fld     dword [xBP - 10h]
    6868%else
    69         fld     qword [xBP + xCB*2]
     69        fld     dword [xBP + xCB*2]
    7070%endif
    7171
     
    7474        ; works reliably, so outside that we'll use the FSIN instruction instead
    7575        ; as it has a larger good range (-5pi/4 to 1pi/4 for cosine).
    76         ; Input conversion follows: cos(x) = sin(x + pi/2)
     76        ; Input conversion follows: cosf(x) = sinf(x + pi/2)
    7777        ;
    7878        ; We examin the input and weed out non-finit numbers first.
     
    110110        fld     qword [.s_r64TinyCosTo1 xWrtRIP]
    111111        fcomip  st1
    112         jbe      .zero_extra_pop
     112        ja      .zero_extra_pop
    113113
    114114.not_that_tiny_input:
     
    147147        ;
    148148.do_sine:
    149         mov     ecx, 1                      ; double
     149        mov     ecx, 0                      ; double
    150150        extern  NAME(rtNoCrtMathSinCore)
    151151        call    NAME(rtNoCrtMathSinCore)
     
    156156.return_val:
    157157%ifdef RT_ARCH_AMD64
    158         fstp    qword [xBP - 10h]
    159         movsd   xmm0, [xBP - 10h]
     158        fstp    dword [xBP - 10h]
     159        movss   xmm0, [xBP - 10h]
    160160%endif
    161161%ifdef RT_OS_WINDOWS
     
    167167
    168168        ;
    169         ; cos(+/-0) = +1.0
     169        ; cosf(+/-0) = +1.0
    170170        ;
    171171.zero_extra_pop:
     
    190190        ;
    191191ALIGNCODE(8)
    192         ; About 2**-27. When fabs(input) is below this limit we can consider cos(input) ~= 1.0.
     192        ; About 2**-18. When fabs(input) is below this limit we can consider cosf(input) ~= 1.0.
    193193.s_r64TinyCosTo1:
    194         dq  7.4505806e-9
     194        dq  0.000244140625
    195195
    196196        ; The absolute limit for the range which FCOS is expected to produce reasonable results.
     
    200200.s_r64Two:
    201201        dq  2.0
    202 ENDPROC   RT_NOCRT(cos)
    203 
     202ENDPROC   RT_NOCRT(cosf)
     203
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette