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 8599315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:22:18+00:00 2026-06-12T01:22:18+00:00

I studied 32 bit machine, and I know sub $12, %esp as same as

  • 0

I studied 32 bit machine, and I know sub $12, %esp as same as three time on pop %eax and mov $0, %eax.

But I don’t know why we use add $18, %rsp with start procedure call or sub $18, %rsp start with procedure call at x86-64 machine.

Why does compiler use this rule for procedure call? Argument rule?

0x0000000000400df3 <main+191>:  mov    $0x402227,%edi
0x0000000000400df8 <main+196>:  callq  0x400ab8 <puts@plt>
0x0000000000400dfd <main+201>:  callq  0x4014c0 <read_line>
0x0000000000400e02 <main+206>:  mov    %rax,%rdi
0x0000000000400e05 <main+209>:  callq  0x401139 <phase_3>

-----------------------------------------------------------------------
example:

0x0000000000401139 <example+0>: sub    $0x18,%rsp
0x000000000040113d <example+4>: lea    0x8(%rsp),%rcx
0x0000000000401142 <example+9>: lea    0xc(%rsp),%rdx
0x0000000000401147 <example+14>:        mov    $0x40248a,%esi
0x000000000040114c <example+19>:        mov    $0x0,%eax
0x0000000000401151 <example+24>:        callq  0x400ac8 <__isoc99_sscanf@plt>
0x0000000000401156 <example+29>:        cmp    $0x1,%eax
  • 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-06-12T01:22:19+00:00Added an answer on June 12, 2026 at 1:22 am

    “I know sub $12, %esp as same as three time on pop %eax and mov $0, %eax.” You know wrong. sub $12, %esp does not change eax, neither by popping into it nor by moving a 0 into it.

    The primary/direct reason for using something like sub $12, %esp is to reserve some space on the stack. That can be used to give some space to local variables of a subroutine. That can also be used to align the stack pointer if it’s desirable for performance or other reasons.

    add $18, %rsp does the reverse, it releases the space previously allocated on the stack. This can be used to free the space occupied by local variables or by the parameters that have been previously passed to another subroutine and aren’t needed on the stack anymore.

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

Sidebar

Related Questions

I know a bit about PHP, but never studied in depth, but now I
I have studied the use of Namespaces in PHP a while back but recently
I've studied the basic turing machine theory as an undergraduate. I never saw any
I have studied generators feature and i think i got it but i would
I've studied some CQRS sample implementations (Java / .Net) which use event sourcing as
I know this question will be closed because I studied many example of this
I hear much talk about memcached , but when briefly studied on it, I
I have studied a bit into the lifespan of the DataContext trying to work
I'm having a bit of a time trying to get Dojo grids (1.5) to
I studied a lot and tried to solve it but I am facing the

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.