]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/LibC/Main/X64/fpu_rmode.asm
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / StdLib / LibC / Main / X64 / fpu_rmode.asm
CommitLineData
2aa62f2b 1;------------------------------------------------------------------------------\r
2; Return the current FPU rounding mode.\r
3;\r
4; MASM implementation of the flt_rounds function from NetBSD.\r
5;\r
6; Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
7; This program and the accompanying materials\r
8; are licensed and made available under the terms and conditions of the BSD License\r
9; which accompanies this distribution. The full text of the license may be found at\r
10; http://opensource.org/licenses/bsd-license.php.\r
11;\r
12; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14;\r
15;------------------------------------------------------------------------------\r
16\r
17 .code\r
18\r
19;_map BYTE 1 ; round to nearest\r
20; BYTE 3 ; round to negative infinity\r
21; BYTE 2 ; round to positive infinity\r
22; BYTE 0 ; round to zero\r
23\r
24;------------------------------------------------------------------------------\r
25; int\r
26; EFIAPI\r
27; fpu_rmode( void );\r
28;\r
29; VC++ always creates space for 4 parameters on the stack, whether they are\r
30; used or not. We use one for temporary storage since the only variant of\r
31; fnstcw saves to memory, NOT a register.\r
32;------------------------------------------------------------------------------\r
33internal_FPU_rmode PROC\r
34 fnstcw [rsp + 8] ; save 16-bit FPU Control Word\r
35 mov eax, [rsp + 8] ; get the saved FPU Control Word\r
36 shr eax, 10\r
37 and rax, 3 ; index is only the LSB two bits in RAX\r
38 ret ; Return rounding mode in RAX\r
39internal_FPU_rmode ENDP\r
40\r
41 END\r