Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6754189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:15:01+00:00 2026-05-26T13:15:01+00:00

I am a bit interested in what does the run time do, so I

  • 0

I am a bit interested in what does the run time do, so I write a simple c program like below.(I do not paste the code of some_function. I think it’s not important.)

int main(int argc, char *argv[]) {
    some_fucntion();
    return;
}

I use i686-apple-darwin10-llvm-gcc-4.2 on my Mac(10.6.8, Intel Core) and compiler the source with following command. Actually I have tried to use O3 and get same result.

gcc -O0 -o test test.c

Then I type following command and get those asm code.

otool -tV test

I get the following asm code. I guess those code relates to prepare the arguments for main function. But I still can’t figure out why there are a loop to set eax to 0x00? And why there are a “jmp” instruction? so the next instruction will never be executed, right?

I would be really appreciate if anyone could explain the whole asm code here. Thanks.

start:
0000000100000d20        pushq   $0x00
0000000100000d22        movq    %rsp,%rbp
0000000100000d25        andq    $0xf0,%rsp
0000000100000d29        movq    0x08(%rbp),%rdi
0000000100000d2d        leaq    0x10(%rbp),%rsi
0000000100000d31        movl    %edi,%edx
0000000100000d33        addl    $0x01,%edx
0000000100000d36        shll    $0x03,%edx
0000000100000d39        addq    %rsi,%rdx
0000000100000d3c        movq    %rdx,%rcx
0000000100000d3f        jmp     0x100000d45
0000000100000d41        addq    $0x08,%rcx
0000000100000d45        cmpq    $0x00,(%rcx)
0000000100000d49        jne     0x100000d41
0000000100000d4b        addq    $0x08,%rcx
0000000100000d4f        callq   _main
0000000100000d54        movl    %eax,%edi
0000000100000d56        callq   0x100000e7c     ; symbol stub for: _exit
0000000100000d5b        hlt
0000000100000d5c        nop
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:15:02+00:00Added an answer on May 26, 2026 at 1:15 pm
    start:
    0000000100000d20        pushq   $0x00               ; push NULL (end of dynamic frame pointer chain)
    0000000100000d22        movq    %rsp,%rbp           ; set frame pointer
    0000000100000d25        andq    $0xf0,%rsp          ; align stack
    0000000100000d29        movq    0x08(%rbp),%rdi     ; mov argc to 1st arg
    0000000100000d2d        leaq    0x10(%rbp),%rsi     ; mov argv to 2nd arg
    0000000100000d31        movl    %edi,%edx           ; \
    0000000100000d33        addl    $0x01,%edx          ; > 3rd arg = argv + (argc + 1) * 8
    0000000100000d36        shll    $0x03,%edx          ; > = envp
    0000000100000d39        addq    %rsi,%rdx           ; /
    0000000100000d3c        movq    %rdx,%rcx           ; \
    0000000100000d3f        jmp     0x100000d45         ; >
    0000000100000d41        addq    $0x08,%rcx          ; > find 1st NULL after envp and
    0000000100000d45        cmpq    $0x00,(%rcx)        ; > move to 4th arg
    0000000100000d49        jne     0x100000d41         ; /
    0000000100000d4b        addq    $0x08,%rcx          ; and add 8 (apple)
    0000000100000d4f        callq   _main               ; call main
    0000000100000d54        movl    %eax,%edi           ; move return value to 1st arg
    0000000100000d56        callq   0x100000e7c         ; and call _exit (doesn't return)
    0000000100000d5b        hlt
    0000000100000d5c        nop
    

    apple is an Apple-specific argument that contains the path to the executable (source).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok hopefully this does not get deleted because I really am interested in some
Probably a bit off topic question, but it's something I'm really interested in getting
Bit of a bizarre question, but does anyone know the actual limit to the
any bit of info will be helpful here. or does anybody else huge do
I am interested in finding out if there exists a program or library which
Does anyone know why Microsoft does not ship a numeric text box with its
I've done quite a bit of research and preparation with my code to try
We Want to Run Our C# Code on the JVM My company has a
I'd like to read a binary file with a few 32 bit float values
I am interested in Cucumber, but am confused a bit. From the website: 1)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.