Changeset 96242 in vbox for trunk/src/VBox/Runtime/common/math
- Timestamp:
- Aug 17, 2022 1:59:06 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 153054
- Location:
- trunk/src/VBox/Runtime/common/math
- Files:
-
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/math/cos.asm
r96240 r96242 110 110 fld qword [.s_r64TinyCosTo1 xWrtRIP] 111 111 fcomip st1 112 j be.zero_extra_pop112 ja .zero_extra_pop 113 113 114 114 .not_that_tiny_input: -
trunk/src/VBox/Runtime/common/math/cosf.asm
r96240 r96242 1 1 ; $Id$ 2 2 ;; @file 3 ; IPRT - No-CRT cos - AMD64 & X86.3 ; IPRT - No-CRT cosf - AMD64 & X86. 4 4 ; 5 5 … … 34 34 35 35 ;; 36 ; Compute the cosine of r d, measured in radians.36 ; Compute the cosine of rf, measured in radians. 37 37 ; 38 38 ; @returns st(0) / xmm0 39 ; @param r d[rbp + xCB*2] / xmm040 ; 41 RT_NOCRT_BEGINPROC cos 39 ; @param rf [rbp + xCB*2] / xmm0 40 ; 41 RT_NOCRT_BEGINPROC cosf 42 42 push xBP 43 43 SEH64_PUSH_xBP … … 64 64 ; 65 65 %ifdef RT_ARCH_AMD64 66 movs d[xBP - 10h], xmm067 fld qword [xBP - 10h]66 movss [xBP - 10h], xmm0 67 fld dword [xBP - 10h] 68 68 %else 69 fld qword [xBP + xCB*2]69 fld dword [xBP + xCB*2] 70 70 %endif 71 71 … … 74 74 ; works reliably, so outside that we'll use the FSIN instruction instead 75 75 ; as it has a larger good range (-5pi/4 to 1pi/4 for cosine). 76 ; Input conversion follows: cos (x) = sin(x + pi/2)76 ; Input conversion follows: cosf(x) = sinf(x + pi/2) 77 77 ; 78 78 ; We examin the input and weed out non-finit numbers first. … … 110 110 fld qword [.s_r64TinyCosTo1 xWrtRIP] 111 111 fcomip st1 112 j be.zero_extra_pop112 ja .zero_extra_pop 113 113 114 114 .not_that_tiny_input: … … 147 147 ; 148 148 .do_sine: 149 mov ecx, 1; double149 mov ecx, 0 ; double 150 150 extern NAME(rtNoCrtMathSinCore) 151 151 call NAME(rtNoCrtMathSinCore) … … 156 156 .return_val: 157 157 %ifdef RT_ARCH_AMD64 158 fstp qword [xBP - 10h]159 movs dxmm0, [xBP - 10h]158 fstp dword [xBP - 10h] 159 movss xmm0, [xBP - 10h] 160 160 %endif 161 161 %ifdef RT_OS_WINDOWS … … 167 167 168 168 ; 169 ; cos (+/-0) = +1.0169 ; cosf(+/-0) = +1.0 170 170 ; 171 171 .zero_extra_pop: … … 190 190 ; 191 191 ALIGNCODE(8) 192 ; About 2**- 27. When fabs(input) is below this limit we can consider cos(input) ~= 1.0.192 ; About 2**-18. When fabs(input) is below this limit we can consider cosf(input) ~= 1.0. 193 193 .s_r64TinyCosTo1: 194 dq 7.4505806e-9194 dq 0.000244140625 195 195 196 196 ; The absolute limit for the range which FCOS is expected to produce reasonable results. … … 200 200 .s_r64Two: 201 201 dq 2.0 202 ENDPROC RT_NOCRT(cos )203 202 ENDPROC RT_NOCRT(cosf) 203 -
trunk/src/VBox/Runtime/common/math/sin.asm
r96241 r96242 35 35 36 36 ;; 37 ; Compute the sine of r d, measured in radians.37 ; Compute the sine of rf, measured in radians. 38 38 ; 39 39 ; @returns st(0) / xmm0 40 ; @param r d[rbp + xCB*2] / xmm040 ; @param rf [rbp + xCB*2] / xmm0 41 41 ; 42 42 RT_NOCRT_BEGINPROC sin … … 160 160 161 161 ALIGNCODE(8) 162 ; Ca. 2**- 26, absolute value. Inputs closer to zero than this can be162 ; Ca. 2**-17, absolute value. Inputs closer to zero than this can be 163 163 ; returns directly as the sin(input) value should be basically the same 164 164 ; given the precision we're working with and FSIN probably won't even … … 166 166 ;; @todo experiment when FSIN gets better than this. 167 167 .s_r64Tiny: 168 dq 1.49011612e-8168 dq 0.00000762939453125 169 169 ; The absolute limit of FSIN "good" range. 170 170 .s_r64FSinOkay: -
trunk/src/VBox/Runtime/common/math/sinf.asm
r96241 r96242 1 1 ; $Id$ 2 2 ;; @file 3 ; IPRT - No-CRT sin - AMD64 & X86.3 ; IPRT - No-CRT sinf - AMD64 & X86. 4 4 ; 5 5 … … 40 40 ; @param rd [rbp + xCB*2] / xmm0 41 41 ; 42 RT_NOCRT_BEGINPROC sin 42 RT_NOCRT_BEGINPROC sinf 43 43 push xBP 44 44 SEH64_PUSH_xBP … … 64 64 ; 65 65 %ifdef RT_ARCH_AMD64 66 movs d[xBP - 10h], xmm067 fld qword [xBP - 10h]66 movss [xBP - 10h], xmm0 67 fld dword [xBP - 10h] 68 68 %else 69 fld qword [xBP + xCB*2]69 fld dword [xBP + xCB*2] 70 70 %endif 71 71 … … 115 115 ; Call common sine/cos worker. 116 116 ; 117 mov ecx, 1 ; double117 mov ecx, 0 ; float 118 118 extern NAME(rtNoCrtMathSinCore) 119 119 call NAME(rtNoCrtMathSinCore) … … 124 124 .return_val: 125 125 %ifdef RT_ARCH_AMD64 126 fstp qword [xBP - 10h]127 movs dxmm0, [xBP - 10h]126 fstp dword [xBP - 10h] 127 movss xmm0, [xBP - 10h] 128 128 %endif 129 129 %ifdef RT_OS_WINDOWS … … 136 136 ; 137 137 ; As explained already, we can return tiny numbers directly too as the 138 ; output from sin (input) = input given our precision.138 ; output from sinf(input) = input given our precision. 139 139 ; We can skip the st0 -> xmm0 translation here, so follow the same path 140 140 ; as .zero & .nan, after we've removed the fabs(input) value. … … 144 144 145 145 ; 146 ; sin (+/-0.0) = +/-0.0 (preserve the sign)146 ; sinf(+/-0.0) = +/-0.0 (preserve the sign) 147 147 ; We can skip the st0 -> xmm0 translation here, so follow the .nan code path. 148 148 ; … … 161 161 ALIGNCODE(8) 162 162 ; Ca. 2**-26, absolute value. Inputs closer to zero than this can be 163 ; returns directly as the sin (input) value should be basically the same163 ; returns directly as the sinf(input) value should be basically the same 164 164 ; given the precision we're working with and FSIN probably won't even 165 165 ; manage that. … … 172 172 ;dq 1.57079632679489661923 ; pi/2 - alternative. 173 173 174 ENDPROC RT_NOCRT(sin )174 ENDPROC RT_NOCRT(sinf) 175 175
Note:
See TracChangeset
for help on using the changeset viewer.