3

I know something is happening with the command line arguments but I don't know what. Can someone walk me through this code?

0x401050    <main>:         push   %ebp
0x401051    <main+1>:       mov    %esp,%ebp
0x401053    <main+3>:       sub    $0x8,%esp
0x401056    <main+6>:       and    $0xfffffff0,%esp
0x401059    <main+9>:       mov    $0x0,%eax
0x40105e    <main+14>:      mov    %eax,0xfffffffc(%ebp)
0x401061    <main+17>:      mov    0xfffffffc(%ebp),%eax
0x401064    <main+20>:      call   0x4013a0 <_alloca>
0x401069    <main+25>:      call   0x401430 <__main>
0x40106e    <main+30>:      mov    $0x0,%edx
0x401073    <main+35>:      add    0x8(%ebp),%edx
0x401076    <main+38>:      mov    %edx,%eax
0x401078    <main+40>:      leave  
0x401079    <main+41>:      ret 

This is IA32 assembly running on linux

1
  • What is the question ?
    – perror
    Aug 12, 2013 at 19:57

1 Answer 1

2

This code doesn't do anything with command line arguments as far as i can see.

What it does is setup the stack and align it. And calls _alloca and __main (if i had to guess, i'd say this is related to c++). Then exits returning 0. This code is very similar to hello.S example on wikibooks, and it has a detailed explanation of what is going on.

Not the answer you're looking for? Browse other questions tagged or ask your own question.