title: c++ class disassembly
body: <p>I have the following code:</p>
  
  <pre><code>class Base {
  public:
  int x,y;
  Base() { x=10; y=20; }
  virtual void myfunction() { }
  };
  
  int main() {
  Base *b = new Base();
  return 0;
  }
  </code></pre>
  
  <p>The disassembly gives me something like:</p>
  
  <pre><code>push 0Ch                ; size of Base
  call j_&lt;some giberrish&gt; ; IDA gives the comment "operator new(uint)"
  add esp, 4              ; function epilogue
  mov [ebp+var_E0], eax
  </code></pre>
  
  <p>A few lines later you have the constructor being called.</p>
  
  <pre><code>mov ecx, [ebp+var_E0]
  call j_Base__Base
  mov [ebp+var_F4], eax
  </code></pre>
  
  <ul>
  <li>At first I had thought that <code>var_E0</code> would contain the pointer to the instance, but now I'm pretty sure that <code>var_F4</code> does as it contains the return value of the constructor. </li>
  <li>In that case, what does <code>var_E0</code> contain at all? Why is it moved into <code>ecx</code> before the constructor is called?</li>
  </ul>