Changeset 96273 in vbox for trunk/src/VBox/Runtime/common/math/tan.asm
- Timestamp:
- Aug 17, 2022 9:01:33 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/math/tan.asm
r96060 r96273 25 25 ; 26 26 27 28 %define RT_ASM_WITH_SEH64 27 29 %include "iprt/asmdefs.mac" 30 %include "iprt/x86.mac" 31 28 32 29 33 BEGINCODE … … 34 38 ; @param rd [xSP + xCB*2] / xmm0 35 39 RT_NOCRT_BEGINPROC tan 36 push xBP 37 mov xBP, xSP 40 push xBP 41 SEH64_PUSH_xBP 42 mov xBP, xSP 43 SEH64_SET_FRAME_xBP 0 44 sub xSP, 20h 45 SEH64_ALLOCATE_STACK 20h 46 SEH64_END_PROLOGUE 38 47 48 %ifdef RT_OS_WINDOWS 49 ; 50 ; Make sure we use full precision and not the windows default of 53 bits. 51 ; 52 fnstcw [xBP - 20h] 53 mov ax, [xBP - 20h] 54 or ax, X86_FCW_PC_64 ; includes both bits, so no need to clear the mask. 55 mov [xBP - 1ch], ax 56 fldcw [xBP - 1ch] 57 %endif 58 59 ; 60 ; Load the input into st0. 61 ; 39 62 %ifdef RT_ARCH_AMD64 40 sub xSP, 10h 63 movsd [xBP - 10h], xmm0 64 fld qword [xBP - 10h] 65 %else 66 fld qword [xBP + xCB*2] 67 %endif 41 68 42 movsd [xSP], xmm0 43 fld qword [xSP] 44 %else 45 fld qword [xBP + xCB*2] 69 ; 70 ; Calculate the tangent. 71 ; 72 fptan 73 fnstsw ax 74 test ah, (X86_FSW_C2 >> 8) ; C2 is set if the input was out of range. 75 jz .return_val 76 77 ; 78 ; Input was out of range, perform reduction to +/-2pi. 79 ; 80 fldpi 81 fadd st0 82 fxch st1 83 .again: 84 fprem1 85 fnstsw ax 86 test ah, (X86_FSW_C2 >> 8) ; C2 is set if partial result. 87 jnz .again ; Loop till C2 == 0 and we have a final result. 88 89 fstp st1 90 91 fptan 92 93 ; 94 ; Run st0. 95 ; 96 .return_val: 97 ffreep st0 ; ignore the 1.0 fptan pushed 98 %ifdef RT_ARCH_AMD64 99 fstp qword [xBP - 10h] 100 movsd xmm0, [xBP - 10h] 46 101 %endif 47 fptan 48 fnstsw ax 49 test ah, 04h ; check for C2 50 jz .done 51 52 fldpi 53 fadd st0 54 fxch st1 55 .again: 56 fprem1 57 fnstsw ax 58 test ah, 04h 59 jnz .again 60 fstp st1 61 fptan 62 63 .done: 64 fstp st0 65 %ifdef RT_ARCH_AMD64 66 fstp qword [xSP] 67 movsd xmm0, [xSP] 102 %ifdef RT_OS_WINDOWS 103 fldcw [xBP - 20h] ; restore original 68 104 %endif 69 leave 70 ret 105 .return: 106 leave 107 ret 71 108 ENDPROC RT_NOCRT(tan) 72 109
Note:
See TracChangeset
for help on using the changeset viewer.