title: Unclear usage of ESI
body: <p>I'm currently looking into assembly and disassembled some code(x86) and there I tried to recreate the C-Code from it. I know at least the basics of the registers and programming in general. But I can't make sense of the usage of ESI in the case of: </p>
  
  <pre><code>mov esi, [esp+10h]
  lea esi, [esi+0]
  </code></pre>
  
  <p>I don't know for sure what <code>esp+10h</code> is in this case, but I don't think it matters, since it should just be some random 32-bit-value, right?</p>
  
  <p>From what I know is that <code>mov esi, [esp+10h]</code> will copy the data(the actual value) from the adress <code>esp+10h</code> and store it in ESI. So <code>esi</code> should be some kind of data right now. But then afterwards <code>lea esi, [esi+0]</code> comes and interprets <code>esi+0</code>, which is data, as an adress and writes this in <code>esi</code>. </p>
  
  <p>In another thread on stackoverflow I read, that <code>lea esi, [esi+0]</code> is actually is a <code>nop</code>(<a href="https://stackoverflow.com/questions/10505690/what-is-the-meaning-of-lea-0x0esi-esi">What is the meaning of lea 0x0(%esi),%esi</a>). That makes sense since it shouldn't modify the address. But that's confusing when <code>esi</code> is data on usage. So my C-code for it looks something like this:</p>
  
  <pre><code>int esi = *(esp + 0x10); //move data from esp+10h to esi
  int* esi = &amp;esi;         //write the address of esi+0 to esi which is
                           //actually an int and not int*
  </code></pre>
  
  <p>So my question is if there is any distinction between data and adress on an register-level or if it's just interpreted as it is since it looks the same(32-bit register). My other question is what this code now actually does and what ESI is at the end? Does <code>mov</code> always copy data? Does <code>lea</code> always copy an address of doesn't it matter anyways?</p>
  
  <p>As you might have guessed by now, I'm pretty confused and maybe I'm just thinking too far. Please have mercy with me :D</p>