title: Assembly for dereferencing a pointer
body: <p>Have just started a visual studio project to look at the assembly for de-referencing a pointer. I had this C++:</p>
  
  <pre><code>int main(){
      std::vector&lt;int&gt;* x = new std::vector&lt;int&gt;();
      x-&gt;resize(10);
      return 1;
  }
  </code></pre>
  
  <p>asm (for the de-referencing):</p>
  
  <pre><code>mov         dword ptr [x],ecx 
      x-&gt;resize(10);
  push        0Ah  
  mov         ecx,dword ptr [x]  
  call        std::vector&lt;int,std::allocator&lt;int&gt; &gt;::resize (0BC124Eh) 
  </code></pre>
  
  <p>I have a few questions about the above:</p>
  
  <ol>
  <li>What does <code>dword ptr[x]</code> actually mean? The pointer address which refers to x?</li>
  <li>Why is the above value copied in to <code>ecx</code>? I understand this is because a function call to <code>resize()</code> is being made, but why ecx register in particular?</li>
  <li>Is the only line of assembly for the dereferencing the <code>mov dword ptr [x],ecx</code> part?</li>
  </ol>
  
  <p>I am trying to understand the cost of a pointer being de-referenced.</p>