Explanation of the disassembly of the simplest program (x86)

Posted by noname on Stack Overflow See other posts from Stack Overflow or by noname
Published on 2010-05-25T00:14:42Z Indexed on 2010/05/25 0:21 UTC
Read the original article Hit count: 648

Filed under:
|
|
|

The following code

int _main() {return 0;}

Compiled using the command:

gcc -s -nostdlib -nostartfiles 01-simple.c -o01-simple.exe

gcc version 4.4.1 (TDM-1 mingw32)

OllyDbg produced this output:

http://imgur.com/g81vK.png

Can you explain what happens here? Analysis so far:

// these two seems to be an idiom:
PUSH EBP        // places EBP on stack
MOV EBP, ESP    // overwrites EBP with ESP

MOV EAX, 0      // EAX = 0

LEAVE          // == mov esp, ebp
               //    pop ebp
               // according to 
               // http://en.wikipedia.org/wiki/X86_instruction_listings

What is the meaning of all this?

© Stack Overflow or respective owner

Related posts about c

    Related posts about assembly