What does this x86 build instruction do (adds xmm0, ds: __ xmm @ 41f00000000000000000000000000000 [edx * 8])?

Can someone explain what the following code does?

addsd xmm0, ds: __xmm@41f00000000000000000000000000000 [edx*8] 

I realized that some value is being added to the float xmm0 register, but what is the meaning of the __xmm @ 41f000000000000000000000000000000 constant? Is there any documentation where I can read about this?

Here is the full code snippet I'm trying to understand:

 cvtsi2sd xmm0, [ebp+var_2C8] mov edx, [ebp+var_2C8] shr edx, 1Fh addsd xmm0, ds: __xmm@41f00000000000000000000000000000 [edx*8] 

ebp + var_2C8 is an unsigned integer value.

  • ebp + var_2C8 is converted to float and moved to register xmm0
  • ebp + var_2C8 moves to edx and moves right 31 bits
  • something derived from this offset is added to xmm0.

What exactly is added to xmm0? Is there a possible goal for this calculation?

Refresh.
Here's the raw parsing for this code:

 cvtsi2sd xmm0,dword ptr [ebp-2C8h] mov edx,dword ptr [ebp-2C8h] shr edx,1Fh addsd xmm0,mmword ptr [edx*8+2685CC0h] 

It looks like some kind of double value from an array of constants is being added to xmm0 ...

+5
source share
1 answer

This is a conversion of an unsigned integer to double.

How it works, it first converts it as signed, which means that the sign bit has a weight of -2 31 but it should be unsigned, where the top bit has a weight of +2 31 . Therefore, if the sign is set, it adds +2 32 = 4294967296.0 (41f0000000000000 as double) to compensate. He does this by shifting to the right, putting the upper bit in the lower bit and clearing everything else, and then uses it as the index of the table in the table containing 0 and 4294967296.0.

+9
source

Source: https://habr.com/ru/post/1238420/


All Articles