Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of a movss instruction with [this] as destination?

I found this line in code generated by the MSVC compiler from Visual Studio 2008, while trying to figure out what seems to be a compiler bug:

movss dword ptr [this], xmm2

Although I do not think it is related to the bug I was looking for, I was like what the bleep? Storing a float value (completely unrelated to this btw) in [this]?

What exactly does that line do? Because I sure can't make sense of it! Or is the disassembly view playing tricks on me?

like image 325
thehan Avatar asked Dec 28 '22 17:12

thehan


1 Answers

Providing some more assembly and/or source code would really help, but I see at least two possibilities:

  1. this is not a this pointer, but just a random register pointing to some memory area. The disassembler named it such because it was used as a this pointer previously in the function or for some other reason.

  2. this does point to a class instance, and the class has a floating-point field as a first member and no virtual methods.

like image 70
Igor Skochinsky Avatar answered Dec 31 '22 15:12

Igor Skochinsky