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