title: how does push and pop work in assembly
body: <p>I'm getting confused on what does <code>pop</code> actually do in assembly. Does <code>pop</code> move the value <code>PUSH</code>ed onto the stack last (meaning it doesn't apply if we <code>MOV</code> a value after the the last element <code>PUSH</code>ed) or does it just pop whatever value that's last on the stack (thus, applying to both <code>MOV</code> and <code>PUSH</code>), or does it pop what ever value pointed to by the stack pointer?    Consider the following code:</p>
  
  <pre><code>push $4
  mov $5, -4(%esp)
  add $4, %esp (esp pointing to an unknown value)
  pop %ebp
  </code></pre>
  
  <p>So in this code will the value poped into <code>ebp</code> be 4, 5, or the unknown value pointed to by <code>esp</code>?</p>