title: In terms of using the stack, why do we need a base pointer and a stack pointer
body: <p>In terms of x86 assembly code anyways. I've been reading about function calls, but still can't fully grasp the need for a base / frame pointer (EBP) along with a stack pointer (ESP).</p>
  
  <p>When we call a function, the current value of EBP will be placed on the stack and then EBP gets the current ESP value.</p>
  
  <p>Place holders for the return value, function arguments and local variables of the function will then be placed on the stack, and the stack pointer ESP value will decrease (or increase) to point to after the last placeholder placed on the stack. </p>
  
  <p>Now we have the EBP pointing to the beginning of the current stack frame, and ESP pointing to the end of the stack frame.</p>
  
  <p>The EBP will be used to access the arguments and local variables of the function due to constant offsets from the EBP. That is fine. What I don't understand is, why can't the ESP just be used to access these variables also by using its offsets. The EBP points to the beginning of the stack frame , and the ESP points to the end of the stack frame. What's the difference?</p>
  
  <p>The ESP shouldn't change from once there has been a placeholder for all the local variables etc. or should it? </p>