title: Understanding stack frames and rbp and rsp with gdb
body: <p>I'm new to assembly lang and I'm a bit confused on some things. For an assignment, I'm given a C program and asked to asked to put breakpoints at two points and count the stack frames and their locations. 
  This is the code :</p>
  
  <pre><code>
  int swap_n_add(int *xp, int *yp) {
  
   int x = *xp;
   int y = *yp;
  
     *xp = y;
     *yp = x;
  
     int sum = x+y;
  
     return sum;
  
  }
  
  int main(int argc, char **argv) {
    int a1 = 534;
    int a2 = 1057;
    int sum = swap_n_add(&amp;a1, &amp;a2);
    int diff = a1-a2;
  
       return sum * diff;
  }
  </code></pre>
  
  <p>So I'm asked to use gdb to examine the stack frames and list their location At the first breakpoint, there's two stack frames .From doing info frame 0: I get the following:</p>
  
  <pre><code>Stack frame at 0x7fffffffe240:
   rip = 0x4004f9 in swap_n_add (swap-n-add.c:7); saved rip 0x40055d
   called by frame at 0x7fffffffe270
   source language c.
   Arglist at 0x7fffffffe230, args: xp=0x7fffffffe254, yp=0x7fffffffe250
   Locals at 0x7fffffffe230, Previous frame's sp is 0x7fffffffe240
   Saved registers:
    rbp at 0x7fffffffe230, rip at 0x7fffffffe238
  </code></pre>
  
  <p>My question is, is rbp is the location or rip? </p>
  
  <p>Another question is, "What are the values stored in rbp and rsp? What does it mean for the stack frame?"</p>
  
  <p>I'm not sure how to answer this because from my understanding, rbp is a stack pointer and changes every time there's a new operation. I might be wrong, but I just don't know how to answer that.</p>
  
  <p>Sorry for the long question, I'm just trying to get my fundamentals right   </p>