Can someone explain what the following code does?
addsd xmm0, ds:__xmm@41f00000000000000000000000000000[edx*8]
I figured that some value is added to float register xmm0, but what is the meaning of __xmm@41f00000000000000000000000000000 constant? Is there any documentation where I can read about it?
Here's the full fragment of code that 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 unsigned integer value.
What exactly is added to xmm0? Is there a possible purpose to this calculation?
Update.
Here's the raw disassembly 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]
Looks like some double value from array of constants is added to xmm0...
x86 assembly language is the name for the family of assembly languages which provide some level of backward compatibility with CPUs back to the Intel 8008 microprocessor, which was launched in April 1972. It is used to produce object code for the x86 class of processors.
mov — Move (Opcodes: 88, 89, 8A, 8B, 8C, 8E, ...) The mov instruction copies the data item referred to by its second operand (i.e. register contents, memory contents, or a constant value) into the location referred to by its first operand (i.e. a register or memory).
%rbp is the base pointer, which points to the base of the current stack frame, and %rsp is the stack pointer, which points to the top of the current stack frame.
"push" stores a constant or 64-bit register out onto the stack. The 64-bit registers are the ones like "rax" or "r8", not the 32-bit registers like "eax" or "r8d". ("push eax" gives an error "instruction not supported in 64-bit mode"; use "push rax" instead.) "pop" retrieves the last value pushed from the stack.
This is the conversion of unsigned integer to double.
How it works is it first converts it as signed, meaning that the sign bit has a weight of -231, but it should be unsigned where the top bit has a weight of +231. So if the sign is set, it adds +232 = 4294967296.0 (41f0000000000000 as double) to compensate. It does so by shifting right, putting the top bit in the bottom bit and clearing everything else, and then it uses that as a table index into a table containing 0 and 4294967296.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With