title: What is the purpose of the RBP register in x86_64 assembler?
body: <p>So I'm trying to learn a little bit of assembly, because I need it for Computer Architecture class. I wrote a few programs, like printing the Fibonacci sequence.</p>
  
  <p>I recognized that whenever I write a function I use those 3 lines (as I learned from comparing assembly code generated from <code>gcc</code> to its <code>C</code> equivalent):</p>
  
  <pre><code>pushq   %rbp
  movq    %rsp, %rbp
  subq    $16, %rsp
  </code></pre>
  
  <p>I have 2 questions about it:</p>
  
  <ol>
  <li>First of all, why do I need to use <code>%rbp</code>? Isn't it simpler to use <code>%rsp</code>, as its contents are moved to <code>%rbp</code> on the 2nd line?</li>
  <li>Why do I have to subtract anything from <code>%rsp</code>? I mean it's not always <code>16</code>, when I was <code>printf</code>ing like 7 or 8 variables, then I would subtract <code>24</code> or <code>28</code>.</li>
  </ol>
  
  <p>I use Manjaro 64 bit on a Virtual Machine (4 GB RAM), Intel 64 bit processor</p>