title: What happens when I move %esp to %ebp?
body: <p>I know this is a pretty basic question, but here it goes:</p>
  
  <p>I am starting to learn Assembler, and I'm trying to understand how the stack works.</p>
  
  <p>At first, when I pass a value to an assembler function, I'd access it like this:</p>
  
  <pre><code>movl 4(%esp),%eax  # first parameter
  movl 8(%esp),%ebx  # second parameter
  </code></pre>
  
  <p>But I then was told that it was better to do this:</p>
  
  <pre><code>push %ebp
  movl %esp,%ebp
  # and then I'd access the values on %ebp:
  movl 8(%ebp),%eax
  movl 12(%ebp),%eax
  pop %ebp
  </code></pre>
  
  <p>Ok, what is the difference here? When I accessed the values directly from %esp, weren't they already on the stack? What's the advantage of using push to do it again? </p>
  
  <p>Does anyone have a tip on a good learning tool (for dummies-type) on how to learn how stack works so one can learn on these stack pointers, return addresses and so on? I haven't found any good visual demonstration on how it works.
  Thanks! </p>