assemblyx86-64program-counter

Difference between rip and eip registers in x86 Assembly


I’m reading a book to learn hacking (it’s called “The art of exploitation” by Jon Erickson) and it starts by writing a C program that prints the “Hello World!” string 10 times, and then analyzing its assembly (intel syntax). In the book the instruction pointer is called “eip”, while on my laptop it’s called “rip”. The same is for many of the others registers (like “ebp -> rbp” and so on). Is there any difference?


Solution

  • The book is written for the 32-bit x86 architecture, which had 32-bit registers named eax, ebp, eip, etc. Your computer, like most present-day x86 machines, is using the 64-bit amd64 (aka x86-64) architecture, which is designed to be similar to 32-bit x86, but among many other differences has 64-bit registers named rax, rbp, rip, etc.

    Although the architectures are similar at a conceptual level, exploitation relies on very specific details. Issues like differences in calling conventions are going to mean that most of this book will not be applicable to 64-bit systems, and is thus obsolete.

    If you want, you can test the book's examples on programs compiled for 32-bit mode (gcc -m32).