title: GDB: Print the value of memory address
body: <p>According to <a href="https://www.ethicalhacker.net/columns/heffner/intro-to-assembly-and-reverse-engineering" rel="nofollow noreferrer">https://www.ethicalhacker.net/columns/heffner/intro-to-assembly-and-reverse-engineering</a></p>
  
  <pre><code>mov 0xffffffb4,0x1
  </code></pre>
  
  <blockquote>
    <p>moves the number 1 into 0xffffffb4.</p>
  </blockquote>
  
  <p>So, I decided to test this on my own.
  In GDB, x  is the command to print the value of memory address.
  However, when I run </p>
  
  <pre><code>x 0x00000000004004fc
  </code></pre>
  
  <p>I'm not getting the value of 133 (decimal) or 85 (hexadecimal)</p>
  
  <p>Instead, I'm getting 0x85f445c7. Any idea what is this?</p>
  
  <pre><code>me@box:~/c$ gdb -q test
  Reading symbols from test...done.
  (gdb) l
  1       #include &lt;stdio.h&gt;
  2
  3       int main(){
  4               int a = 1;
  5               int b = 13;
  6               int c = 133;
  7               printf("Value of C : %d\n",c);
  8               return 0;
  9       }
  (gdb) b 7
  Breakpoint 1 at 0x400503: file test.c, line 7.
  (gdb) r
  Starting program: /home/me/c/test 
  
  Breakpoint 1, main () at test.c:7
  7               printf("Value of C : %d\n",c);
  (gdb) 
  </code></pre>
  
  <p>Disassemble</p>
  
  <pre><code>(gdb) disas
  Dump of assembler code for function main:
     0x00000000004004e6 &lt;+0&gt;:     push   %rbp
     0x00000000004004e7 &lt;+1&gt;:     mov    %rsp,%rbp
     0x00000000004004ea &lt;+4&gt;:     sub    $0x10,%rsp
     0x00000000004004ee &lt;+8&gt;:     movl   $0x1,-0x4(%rbp)
     0x00000000004004f5 &lt;+15&gt;:    movl   $0xd,-0x8(%rbp)
     0x00000000004004fc &lt;+22&gt;:    movl   $0x85,-0xc(%rbp)
  =&gt; 0x0000000000400503 &lt;+29&gt;:    mov    -0xc(%rbp),%eax
     0x0000000000400506 &lt;+32&gt;:    mov    %eax,%esi
     0x0000000000400508 &lt;+34&gt;:    mov    $0x4005a4,%edi
     0x000000000040050d &lt;+39&gt;:    mov    $0x0,%eax
     0x0000000000400512 &lt;+44&gt;:    callq  0x4003c0 &lt;printf@plt&gt;
     0x0000000000400517 &lt;+49&gt;:    mov    $0x0,%eax
     0x000000000040051c &lt;+54&gt;:    leaveq 
     0x000000000040051d &lt;+55&gt;:    retq   
  End of assembler dump.
  (gdb) x 0x00000000004004fc
  0x4004fc &lt;main+22&gt;:     0x85f445c7
  (gdb)
  </code></pre>