VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/math/powf.asm@ 96338

最後變更 在這個檔案從96338是 96338,由 vboxsync 提交於 3 年 前

IPRT/nocrt: Implemented powf. bugref:10261

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.0 KB
 
1; $Id: powf.asm 96338 2022-08-19 15:07:12Z vboxsync $
2;; @file
3; IPRT - No-CRT powf - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2022 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.alldomusa.eu.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27
28%define RT_ASM_WITH_SEH64
29%include "iprt/asmdefs.mac"
30%include "iprt/x86.mac"
31
32
33BEGINCODE
34
35extern NAME(rtNoCrtMathPowCore)
36
37;;
38; Compute the rfBase to the power of rfExp.
39; @returns st(0) / xmm0
40; @param rfBase [xSP + xCB*2] / xmm0
41; @param rfExp [xSP + xCB*2 + 4] / xmm1
42;
43RT_NOCRT_BEGINPROC powf
44 push xBP
45 SEH64_PUSH_xBP
46 mov xBP, xSP
47 SEH64_SET_FRAME_xBP 0
48 push xBX
49 SEH64_PUSH_GREG rbx
50 sub xSP, 30h - xCB
51 SEH64_ALLOCATE_STACK 30h - xCB
52 SEH64_END_PROLOGUE
53
54 ;
55 ; Load rdBase into st1 and rdExp into st0.
56 ;
57%ifdef RT_ARCH_AMD64
58 movss [xBP - 20h], xmm0
59 fld dword [xBP - 20h]
60 fxam
61 fnstsw ax
62 mov dx, ax ; dx=fxam(base)
63
64 movss [xBP - 30h], xmm1
65 fld dword [xBP - 30h]
66%else
67 fld dword [xBP + xCB*2]
68 fxam
69 fnstsw ax
70 mov dx, ax ; dx=fxam(base)
71
72 fld dword [xBP + xCB*2 + RTLRD_CB]
73%endif
74
75 ;
76 ; Call common worker for the calculation.
77 ;
78 mov ebx, 1 ; float
79 call NAME(rtNoCrtMathPowCore)
80
81 ;
82 ; Normally, we return with eax==0 and we have to load the result
83 ; from st0 and into xmm0.
84 ;
85 cmp eax, 0
86 jne .return_input_reg
87
88 fstp dword [xSP - 30h]
89 movss xmm0, [xSP - 30h]
90
91.return:
92 lea xSP, [xBP - xCB]
93 pop xBX
94 leave
95 ret
96
97 ;
98 ; But sometimes, like if we have NaN or other special inputs, we should
99 ; return the input as-is and ditch the st0 value.
100 ;
101.return_input_reg:
102 ffreep st0
103 cmp eax, 2
104 je .return_exp
105%ifdef RT_STRICT
106 cmp eax, 1
107 je .return_base
108 int3
109%endif
110.return_base:
111 jmp .return
112
113.return_exp:
114 movss xmm0, xmm1
115 jmp .return
116ENDPROC RT_NOCRT(powf)
117
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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