title: How does the EIP register get its value?
body: <p>I've just started to learn assembly in school, and we're starting to dive into registers and how to use them.
  A point that I can't seem to understand is how does the instruction pointer get the address of the next instruction? 
  For instance take the following code:</p>
  
  <pre><code>nop
  pushl    %ebp
  movl    %esp, %ebp
  subl    $4, %esp
  </code></pre>
  
  <p>In the previous code the instruction pointer gets incremented after each line, and I'd like to know how does it know which instruction to do next (i.e <code>mov</code>,<code>sub</code>,<code>push</code>,...etc.)? Are all the previous instruction first loaded into RAM when we first run the program and the address of the first instruction (<code>nop</code> in this case) gets automatically loaded into <code>eip</code>, then it just goes over them one by one? Or am I missing something?</p>
  
  <p>Any help is appreciated.</p>