VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/math/fesetexceptflag.asm

Last change on this file was 98103, checked in by vboxsync, 16 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.7 KB
Line 
1; $Id: fesetexceptflag.asm 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; IPRT - No-CRT fesetexceptflag - 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
44
45;;
46; Gets the pending exceptions.
47;
48; @returns eax = 0 on success, non-zero on failure.
49; @param pfXcpts 32-bit: [xBP+8]; msc64: rcx; gcc64: rdi; -- pointer to fexcept_t (16-bit)
50; @param fXcptMask 32-bit: [xBP+c]; msc64: edx; gcc64: esi; -- X86_MXCSR_XCPT_FLAGS (X86_FSW_XCPT_MASK)
51; Accepts X86_FSW_SF.
52;
53RT_NOCRT_BEGINPROC fesetexceptflag
54 push xBP
55 SEH64_PUSH_xBP
56 mov xBP, xSP
57 SEH64_SET_FRAME_xBP 0
58 sub xSP, 10h
59 SEH64_ALLOCATE_STACK 20h
60 SEH64_END_PROLOGUE
61
62 ;
63 ; Load the parameter into ecx (*pfXcpts) and edx (fXcptMask) and validate the latter.
64 ;
65%ifdef ASM_CALL64_GCC
66 movzx ecx, word [rdi]
67 mov edx, esi
68%elifdef ASM_CALL64_MSC
69 movzx ecx, word [rcx]
70%elifdef RT_ARCH_X86
71 mov ecx, [xBP + xCB*2]
72 movzx ecx, word [ecx]
73 mov edx, [xBP + xCB*3]
74%endif
75%if 0
76 and ecx, X86_FSW_XCPT_MASK
77 and edx, X86_FSW_XCPT_MASK
78%else
79 or eax, -1
80 test edx, ~X86_FSW_XCPT_MASK
81 jnz .return
82 test ecx, ~X86_FSW_XCPT_MASK
83 jnz .return
84%endif
85
86 ;
87 ; Apply the AND mask to ECX and invert it so we can use it to clear flags
88 ; before OR'ing in the new values.
89 ;
90 and ecx, edx
91 not edx
92
93 ;
94 ; Make the modifications
95 ;
96
97 ; Modify the pending x87 exceptions (FSW).
98 fnstenv [xBP - 20h]
99 and [xBP - 20h + X86FSTENV32P.FSW], dx
100 or [xBP - 20h + X86FSTENV32P.FSW], cx
101 fldenv [xSP - 20h]
102
103%ifdef RT_ARCH_X86
104 ; SSE supported (ecx preserved)?
105 extern NAME(rtNoCrtHasSse)
106 call NAME(rtNoCrtHasSse)
107 test al, al
108 jz .return_ok
109%endif
110
111 ; Modify the pending SSE exceptions (same bit positions as in FSW).
112 stmxcsr [xBP - 10h]
113 mov eax, [xBP - 10h]
114 or edx, X86_FSW_XCPT_MASK & ~X86_MXCSR_XCPT_FLAGS ; Don't mix X86_FSW_SF with X86_MXCSR_DAZ.
115 and ecx, X86_MXCSR_XCPT_FLAGS ; Ditto
116 and eax, edx
117 or eax, ecx
118 mov [xBP - 10h], eax
119 ldmxcsr [xBP - 10h]
120
121.return_ok:
122 xor eax, eax
123.return:
124 leave
125 ret
126ENDPROC RT_NOCRT(fesetexceptflag)
127
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use