VirtualBox

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

Last change on this file since 96338 was 96338, checked in by vboxsync, 2 years ago

IPRT/nocrt: Implemented powf. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1; $Id: pow.asm 96338 2022-08-19 15:07:12Z vboxsync $
2;; @file
3; IPRT - No-CRT pow - 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.virtualbox.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 rdBase to the power of rdExp.
39; @returns st(0) / xmm0
40; @param rdBase [xSP + xCB*2] / xmm0
41; @param rdExp [xSP + xCB*2 + 8] / xmm1
42;
43RT_NOCRT_BEGINPROC pow
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 movsd [xBP - 20h], xmm0
59 fld qword [xBP - 20h]
60 fxam
61 fnstsw ax
62 mov dx, ax ; dx=fxam(base)
63
64 movsd [xBP - 30h], xmm1
65 fld qword [xBP - 30h]
66%else
67 fld qword [xBP + xCB*2]
68 fxam
69 fnstsw ax
70 mov dx, ax ; dx=fxam(base)
71
72 fld qword [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 qword [xSP - 30h]
89 movsd 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 movsd xmm0, xmm1
115 jmp .return
116ENDPROC RT_NOCRT(pow)
117
Note: See TracBrowser for help on using the repository browser.

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