The MASM Forum

General => The Campus => Topic started by: Mikl__ on July 14, 2020, 11:33:19 AM

Title: Replace FPU-instructions to SSE-instructions
Post by: Mikl__ on July 14, 2020, 11:33:19 AM
Hi, All !
xorps xmm0, xmm0
subss xmm0, xmm1; in the register xmm1 the value for which you want to change the sign
movss xmm1, xmm0
or soxorps xmm0, const80000000hBut is that right?
Thank you
Title: Re: Replace FPU-instructions to SSE-instructions
Post by: hutch-- on July 14, 2020, 12:08:10 PM
I have seen formulas around the internet for replacing trig functions with sse2. The attached PDF is what I have found so far.
Title: Re: Replace FPU-instructions to SSE-instructions
Post by: TouEnMasm on July 14, 2020, 02:52:25 PM

The answer must be in the CRT using /Fa to get an asm translate.
Perhaps also is there some options to switch on in VS project.

Title: Re: Replace FPU-instructions to SSE-instructions
Post by: Siekmanski on July 14, 2020, 03:44:25 PM
Floating point has 1 sign bit.
So we can flip the sign bit using boolean algebra ( Exclusive OR )

pxor / xorps / xorpd

.const
flip_bit dd 080000000H,080000000H,080000000H,080000000H

.code

xorps xmm0,dword ptr [flip_bit]
4 at once:
xorps xmm0,oword ptr [flip_bit]

square root functions in SSE:

SQRTSD Compute Square Root of Scalar Double-Precision Floating-Point Value
SQRTSS Compute Square Root of Scalar Single-Precision Value
SQRTPD Square Root of Packed Double-Precision Floating-Point Values
SQRTPS Square Root of Packed Single-Precision Floating-Point Values

RSQRTPS Compute Reciprocals of Square Roots of Packed Single-Precision Floating-Point Values
RSQRTSS Compute Reciprocal of Square Root of Scalar Single-Precision Floating-Point Value

Other trigonometric functions you have to create yourself.

for example: http://masm32.com/board/index.php?topic=4118.msg49276#msg49276
Title: Re: Replace FPU-instructions to SSE-instructions
Post by: Mikl__ on July 14, 2020, 05:33:32 PM
Hi, hutch--, TouEnMasm, Siekmanski
Thank you very much (https://wasm.in/styles/smiles_s/thank_you2.gif)
Title: Re: Replace FPU-instructions to SSE-instructions
Post by: daydreamer on July 14, 2020, 11:37:10 PM
well sometimes you can eliminate change sign if you have mulps later in calculation
constants or variables for example taylor series use 1/3!,-1/5!,1/7!,-1/9!
use mulps -100.0, instead change sign and mulps 100.0


Title: Re: Replace FPU-instructions to SSE-instructions
Post by: Mikl__ on July 15, 2020, 10:36:08 AM
Hi, daydreamer!
I will use your advice. Thank!