Changeset 96203 in vbox for trunk/src/VBox/Runtime/common/math
- Timestamp:
- Aug 14, 2022 3:27:49 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 153011
- Location:
- trunk/src/VBox/Runtime/common/math
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/math/rint.asm
r96117 r96203 25 25 ; 26 26 27 27 28 %define RT_ASM_WITH_SEH64 28 29 %include "iprt/asmdefs.mac" 30 %include "iprt/x86.mac" 31 29 32 30 33 BEGINCODE … … 48 51 SEH64_END_PROLOGUE 49 52 53 ; 54 ; Load the value into st(0). This messes up SNaN values. 55 ; 50 56 %ifdef RT_ARCH_AMD64 51 57 movsd qword [xSP], xmm0 52 58 fld qword [xSP] 59 %else 60 fld qword [xBP + xCB*2] 61 %endif 62 63 ; 64 ; Return immediately if NaN or infinity. 65 ; 66 fxam 67 fstsw ax 68 test ax, X86_FSW_C0 ; C0 is set for NaN, Infinity and Empty register. The latter is not the case. 69 jz .input_ok 70 %ifdef RT_ARCH_AMD64 71 ffreep st0 ; return the xmm0 register value unchanged, as FLD changes SNaN to QNaN. 72 %endif 73 jmp .return 74 .input_ok: 75 76 ; 77 ; Do the job and return. 78 ; 53 79 frndint 80 81 %ifdef RT_ARCH_AMD64 54 82 fstp qword [xSP] 55 83 movsd xmm0, qword [xSP] 56 %else57 fld qword [xBP + xCB*2]58 frndint59 84 %endif 60 85 .return: 61 86 leave 62 87 ret -
trunk/src/VBox/Runtime/common/math/rintf.asm
r96121 r96203 25 25 ; 26 26 27 27 28 %define RT_ASM_WITH_SEH64 28 29 %include "iprt/asmdefs.mac" 30 %include "iprt/x86.mac" 31 29 32 30 33 BEGINCODE … … 48 51 SEH64_END_PROLOGUE 49 52 53 ; 54 ; Load the value into st(0). This messes up SNaN values. 55 ; 50 56 %ifdef RT_ARCH_AMD64 51 57 movss dword [xSP], xmm0 52 58 fld dword [xSP] 59 %else 60 fld dword [xBP + xCB*2] 61 %endif 62 63 ; 64 ; Return immediately if NaN or infinity. 65 ; 66 fxam 67 fstsw ax 68 test ax, X86_FSW_C0 ; C0 is set for NaN, Infinity and Empty register. The latter is not the case. 69 jz .input_ok 70 %ifdef RT_ARCH_AMD64 71 ffreep st0 ; return the xmm0 register value unchanged, as FLD changes SNaN to QNaN. 72 %endif 73 jmp .return 74 .input_ok: 75 76 ; 77 ; Do the job and return. 78 ; 53 79 frndint 80 81 %ifdef RT_ARCH_AMD64 54 82 fstp dword [xSP] 55 83 movss xmm0, dword [xSP] 56 %else57 fld dword [xBP + xCB*2]58 frndint59 84 %endif 60 85 .return: 61 86 leave 62 87 ret -
trunk/src/VBox/Runtime/common/math/trunc.asm
r96014 r96203 26 26 27 27 28 %define RT_ASM_WITH_SEH64 28 29 %include "iprt/asmdefs.mac" 30 %include "iprt/x86.mac" 31 29 32 30 33 BEGINCODE … … 35 38 ; @param rd 32-bit: [ebp + 8] 64-bit: xmm0 36 39 RT_NOCRT_BEGINPROC trunc 37 push xBP 38 mov xBP, xSP 39 sub xSP, 10h 40 push xBP 41 SEH64_PUSH_xBP 42 mov xBP, xSP 43 SEH64_SET_FRAME_xBP 0 44 sub xSP, 10h 45 SEH64_ALLOCATE_STACK 10h 46 SEH64_END_PROLOGUE 47 48 ; 49 ; Load the value into st(0). This messes up SNaN values. 50 ; 51 %ifdef RT_ARCH_AMD64 52 movsd [xSP], xmm0 53 fld qword [xSP] 54 %else 55 fld qword [xBP + xCB*2] 56 %endif 57 58 ; 59 ; Return immediately if NaN or infinity. 60 ; 61 fxam 62 fstsw ax 63 test ax, X86_FSW_C0 ; C0 is set for NaN, Infinity and Empty register. The latter is not the case. 64 jz .input_ok 65 %ifdef RT_ARCH_AMD64 66 ffreep st0 ; return the xmm0 register value unchanged, as FLD changes SNaN to QNaN. 67 %endif 68 jmp .return_val 69 .input_ok: 70 71 ; 72 ; Make it truncate up by modifying the fpu control word. 73 ; 74 fstcw [xBP - 10h] 75 mov eax, [xBP - 10h] 76 or eax, X86_FCW_RC_ZERO ; both bits set, so no need to clear anything first. 77 mov [xBP - 08h], eax 78 fldcw [xBP - 08h] 79 80 ; 81 ; Round ST(0) to integer. 82 ; 83 frndint 84 85 ; 86 ; Restore the fpu control word and return. 87 ; 88 fldcw [xBP - 10h] 40 89 41 90 %ifdef RT_ARCH_AMD64 42 movsd [xSP], xmm0 43 fld qword [xSP] 44 %else 45 fld qword [xBP + xCB*2] 91 fstp qword [xSP] 92 movsd xmm0, [xSP] 46 93 %endif 47 48 ; Make it truncate up by modifying the fpu control word. 49 fstcw [xBP - 10h] 50 mov eax, [xBP - 10h] 51 or eax, 00c00h 52 mov [xBP - 08h], eax 53 fldcw [xBP - 08h] 54 55 ; Round ST(0) to integer. 56 frndint 57 58 ; Restore the fpu control word. 59 fldcw [xBP - 10h] 60 61 %ifdef RT_ARCH_AMD64 62 fstp qword [xSP] 63 movsd xmm0, [xSP] 64 %endif 65 leave 66 ret 94 .return_val: 95 leave 96 ret 67 97 ENDPROC RT_NOCRT(trunc) 68 98 -
trunk/src/VBox/Runtime/common/math/truncf.asm
r96014 r96203 26 26 27 27 28 %define RT_ASM_WITH_SEH64 28 29 %include "iprt/asmdefs.mac" 30 %include "iprt/x86.mac" 31 29 32 30 33 BEGINCODE … … 35 38 ; @param rf 32-bit: [ebp + 8] 64-bit: xmm0 36 39 RT_NOCRT_BEGINPROC truncf 37 push xBP 38 mov xBP, xSP 39 sub xSP, 10h 40 push xBP 41 SEH64_PUSH_xBP 42 mov xBP, xSP 43 SEH64_SET_FRAME_xBP 0 44 sub xSP, 10h 45 SEH64_ALLOCATE_STACK 10h 46 SEH64_END_PROLOGUE 47 48 ; 49 ; Load the value into st(0). This messes up SNaN values. 50 ; 51 %ifdef RT_ARCH_AMD64 52 movss [xSP], xmm0 53 fld dword [xSP] 54 %else 55 fld dword [xBP + xCB*2] 56 %endif 57 58 ; 59 ; Return immediately if NaN or infinity. 60 ; 61 fxam 62 fstsw ax 63 test ax, X86_FSW_C0 ; C0 is set for NaN, Infinity and Empty register. The latter is not the case. 64 jz .input_ok 65 %ifdef RT_ARCH_AMD64 66 ffreep st0 ; return the xmm0 register value unchanged, as FLD changes SNaN to QNaN. 67 %endif 68 jmp .return_val 69 .input_ok: 70 71 ; 72 ; Make it truncate up by modifying the fpu control word. 73 ; 74 fstcw [xBP - 10h] 75 mov eax, [xBP - 10h] 76 or eax, X86_FCW_RC_ZERO ; both bits set, so no need to clear anything first. 77 mov [xBP - 08h], eax 78 fldcw [xBP - 08h] 79 80 ; 81 ; Round ST(0) to integer. 82 ; 83 frndint 84 85 ; 86 ; Restore the fpu control word and return. 87 ; 88 fldcw [xBP - 10h] 40 89 41 90 %ifdef RT_ARCH_AMD64 42 movss [xSP], xmm0 43 fld dword [xSP] 44 %else 45 fld dword [xBP + xCB*2] 91 fstp dword [xSP] 92 movss xmm0, [xSP] 46 93 %endif 47 48 ; Make it truncate up by modifying the fpu control word. 49 fstcw [xBP - 10h] 50 mov eax, [xBP - 10h] 51 or eax, 00c00h 52 mov [xBP - 08h], eax 53 fldcw [xBP - 08h] 54 55 ; Round ST(0) to integer. 56 frndint 57 58 ; Restore the fpu control word. 59 fldcw [xBP - 10h] 60 61 %ifdef RT_ARCH_AMD64 62 fstp dword [xSP] 63 movss xmm0, [xSP] 64 %endif 65 leave 66 ret 94 .return_val: 95 leave 96 ret 67 97 ENDPROC RT_NOCRT(truncf) 68 98 -
trunk/src/VBox/Runtime/common/math/truncl.asm
r96014 r96203 26 26 27 27 28 %define RT_ASM_WITH_SEH64 28 29 %include "iprt/asmdefs.mac" 30 %include "iprt/x86.mac" 31 29 32 30 33 BEGINCODE … … 33 36 ; Round to truncated integer value. 34 37 ; @returns st(0) 35 ; @param rd[rbp + 8]38 ; @param lrd [rbp + 8] 36 39 RT_NOCRT_BEGINPROC truncl 37 push xBP 38 mov xBP, xSP 39 sub xSP, 10h 40 push xBP 41 SEH64_PUSH_xBP 42 mov xBP, xSP 43 SEH64_SET_FRAME_xBP 0 44 sub xSP, 10h 45 SEH64_ALLOCATE_STACK 10h 46 SEH64_END_PROLOGUE 40 47 41 fld tword [xBP + xCB*2]48 fld tword [xBP + xCB*2] 42 49 43 ; Make it truncate up by modifying the fpu control word.44 fstcw [xBP - 10h]45 mov eax, [xBP - 10h]46 or eax, 00c00h47 mov [xBP - 08h], eax48 fldcw [xBP - 08h]50 ; Make it truncate up by modifying the fpu control word. 51 fstcw [xBP - 10h] 52 mov eax, [xBP - 10h] 53 or eax, X86_FCW_RC_ZERO ; both bits set, so no need to clear anything first. 54 mov [xBP - 08h], eax 55 fldcw [xBP - 08h] 49 56 50 ; Round ST(0) to integer.51 frndint57 ; Round ST(0) to integer. 58 frndint 52 59 53 ; Restore the fpu control word.54 fldcw [xBP - 10h]60 ; Restore the fpu control word. 61 fldcw [xBP - 10h] 55 62 56 leave57 ret63 leave 64 ret 58 65 ENDPROC RT_NOCRT(truncl) 59 66
Note:
See TracChangeset
for help on using the changeset viewer.