Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>Your machine is <em>64</em> bit, not 63 bit =). You were able to read the the 32-bit registers because you are compiling and running your program as a 32-bit executable[1].</li> <li>You are unable to read the 64-bit registers because you are compiling and running your program as a 32-bit executable. Yes, you have a 64-bit processor, but it can still run 32-bit executables (if your OS supports it, which yours clearly does), and evidently your compiler tool chain builds 32-bit by default. If you are using <code>gcc</code>, try using the <code>-m64</code> flag, or read the compiler documentation for more information.</li> <li>Unlike <code>rip</code>, the <code>eip</code> register cannot be directly accessed. You can get the value of <code>eip</code> in the manner described by <strong>Jim</strong> in his answer.</li> </ol> <p>[1] you would be able to read the 32-bit registers from a 64-bit executable anyway; the 32-bit registers are still available in 64-bit mode, just like you can access the 16-bit registers in 32-bit mode.</p> <hr> <p>There are a few problems still in your example:</p> <p>First, although <code>rip</code> is accessible in 64-bit mode, it's accessible as an addressing mode; it's not a normal register. If you want to load its value, you need to use <code>LEA</code>, not <code>MOV</code>.</p> <p>Second, because <code>rip</code> is a 64-bit register, you need to use the <code>q</code> suffix on your instructions instead of <code>l</code>. Here's a sample program with these two issues addressed:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;inttypes.h&gt; int main(int argc, char *argv[]) { uint64_t ip; asm("leaq (%%rip), %0;": "=r"(ip)); printf("rip is 0x%016" PRIx64 "\n", ip); return 0; } </code></pre> <p>which seems to work just fine on my machine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload