VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/math/feupdateenv.asm@ 99553

Last change on this file since 99553 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1; $Id: feupdateenv.asm 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; IPRT - No-CRT feupdateenv - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2022-2023 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37
38%define RT_ASM_WITH_SEH64
39%include "iprt/asmdefs.mac"
40%include "iprt/x86.mac"
41
42
43BEGINCODE
44extern NAME(RT_NOCRT(fesetenv))
45extern NAME(RT_NOCRT(feraiseexcept))
46
47
48;;
49; Updates the FPU+SSE environment.
50;
51; This will restore @a pEnv and merge in pending exception flags.
52;
53; @returns eax = 0 on success, -1 on failure.
54; @param pEnv 32-bit: [xBP+8] msc64: rcx gcc64: rdi - Saved environment.
55;
56RT_NOCRT_BEGINPROC feupdateenv
57 push xBP
58 SEH64_PUSH_xBP
59 mov xBP, xSP
60 SEH64_SET_FRAME_xBP 0
61 sub xSP, 30h
62 SEH64_ALLOCATE_STACK 30h
63 SEH64_END_PROLOGUE
64
65 ;
66 ; Load the parameter into rcx.
67 ;
68%ifdef ASM_CALL64_GCC
69 mov rcx, rdi
70%elifdef RT_ARCH_X86
71 mov ecx, [xBP + xCB*2]
72%endif
73
74 ;
75 ; Save the pending exceptions.
76 ;
77%ifdef RT_ARCH_X86
78 extern NAME(rtNoCrtHasSse)
79 call NAME(rtNoCrtHasSse) ; Preserves all except xAX.
80 xor edx, edx
81 test al, al
82 jz .no_sse
83%endif
84 stmxcsr [xBP - 10h]
85 mov edx, [xBP - 10h]
86 and edx, X86_MXCSR_XCPT_FLAGS
87.no_sse:
88 fnstsw ax
89 or edx, eax
90 mov [xBP - 8h], edx ; save the pending exceptions here (will apply X86_FSW_XCPT_MASK later).
91
92 ;
93 ; Call fesetenv to update the environment.
94 ; Note! We have not yet modified the parameter registers for calling
95 ; convensions using them. So, parameters only needs to be loaded
96 ; for the stacked based convention.
97 ;
98%ifdef RT_ARCH_X86
99 mov [xSP], ecx
100%endif
101 call NAME(RT_NOCRT(fesetenv))
102
103 ;
104 ; Raise exceptions if any are pending.
105 ;
106%ifdef ASM_CALL64_GCC
107 mov edi, [xBP - 8h]
108 and edi, X86_FSW_XCPT_MASK
109%elifdef ASM_CALL64_MSC
110 mov ecx, [xBP - 8h]
111 and ecx, X86_FSW_XCPT_MASK
112%else
113 mov ecx, [xBP - 8h]
114 and ecx, X86_FSW_XCPT_MASK
115 mov [xSP], ecx
116%endif
117 jz .no_exceptions_to_raise
118 call NAME(RT_NOCRT(feraiseexcept))
119.no_exceptions_to_raise:
120
121 ;
122 ; Return success.
123 ;
124 xor eax, eax
125 leave
126 ret
127ENDPROC RT_NOCRT(feupdateenv)
128
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