I have been trying to compile this C program to assembly but it hasn't been working fine.
I am reading Dennis Yurichev Reverse Engineering for Beginner but I am not getting the same output. Its a simple hello world statement. I am trying to get the 32 bit output
#include <stdio.h>
int main()
{
     printf("hello, world\n");
     return 0;
}
Here is what the book says the output should be
   main proc near
    var_10 = dword ptr -10h
    push ebp
    mov ebp, esp
    and esp, 0FFFFFFF0h
    sub esp, 10h
    mov eax, offset aHelloWorld ; "hello, world\n"
    mov [esp+10h+var_10], eax
    call _printf
    mov eax, 0
    leave
    retn
    main endp
Here are the steps;
- Compile the print statement as a 32bit (I am currently running a 64bit pc) - gcc -m32 hello_world.c -o hello_world
 
- Use gdb to disassemble - gdb file
- set disassembly-flavor intel
- set architecture i386:intel disassemble main
 
And i get;
    lea    ecx,[esp+0x4]
    and    esp,0xfffffff0
    push   DWORD PTR [ecx-0x4]
    push   ebp
    mov    ebp,esp
    push   ebx
    push   ecx
    call   0x565561d5 <__x86.get_pc_thunk.ax>
    add    eax,0x2e53
    sub    esp,0xc
    lea    edx,[eax-0x1ff8]
    push   edx
    mov    ebx,eax
    call   0x56556030 <puts@plt>
    add    esp,0x10
    mov    eax,0x0
    lea    esp,[ebp-0x8]
    pop    ecx
    pop    ebx
    pop    ebp
    lea    esp,[ecx-0x4]
    ret 
I have also used
objdump -D -M i386,intel hello_world> hello_world.txt
ndisasm -b32 hello_world > hello_world.txt
But none of those are working either. I just cant figure out what's wrong. I need some help. Looking at you Peter Cordes ^^
 
     
     
    