title: Assembly: why do we subtract esp if the push command already does the subtraction?
body: <p>According to disassembler, there are some functions look like</p>
  
  <pre><code>sub esp, 0x20
  push some registers
  do some stuffs
  pop the registers
  add esp, 0x20
  ret
  </code></pre>
  
  <p>At first I thought it was to allocate memory for local variables, but I realize there are other functions look like just simply</p>
  
  <pre><code>push some registers
  do stuffs
  pop some registers
  ret
  </code></pre>
  
  <p>which does not subtract esp manually.</p>
  
  <p>I have done some searching and apparently the push command already automatically subtract esp for the size of the value pushed; if this is the case, then why in the first function we still need to manually subtract esp at the beginning of the function? Or in other words, what exactly is the difference in purpose between the two functions?</p>