In this article, we will learn how to construct C code from x86 assembly for pointers. The article is divided into two parts. In the first part, we will write C code and analyze the corresponding x86 assembly code. And, in the second part, we will analyze the x86 assembly code and try to construct the corresponding C code that uses pointers.
Let’s write a small piece of C code:
#include <stdio.h> int main() { int *a; *a = 1; return 0; }
Now, let’s compile the C code using the GCC compiler and look into the corresponding assembly code:
$ gcc pointers.c $ objdump -M intel -d a.out
Please note that the “-M intel” option will generate the x86 assembly code in the Intel syntax.
0000000000000000 <main>: 0: push rbp 1: mov rbp,rsp 4: mov rax,QWORD PTR [rbp-0x8] 8: mov DWORD PTR [rax],0x1 e: mov eax,0x0 13: pop rbp 14: ret






0 Comments