This is the mail archive of the
mailing list for the GCC project.
Re: gcc-4.9.2: Assembly for i386 Target
- From: Stefan Ring <stefanrin at gmail dot com>
- To: Abhishek Aggarwal <abhiinnitald at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 12 Oct 2015 11:40:48 +0200
- Subject: Re: gcc-4.9.2: Assembly for i386 Target
- Authentication-results: sourceware.org; auth=none
- References: <CAGy+Z4jBeMpFEJ6qmPtHbK9c1sbNvhJcNKS=ARcikgSBhHLzvg at mail dot gmail dot com>
On Mon, Oct 12, 2015 at 11:11 AM, Abhishek Aggarwal
> I was befuddled by the following 3 assembly instructions (generated
> right in the beginning of 'main' function):
> lea 0x4(%esp), %ecx
> and 0xfffffff0, %esp
> pushl -0x4(%ecx)
> I am not able to understand the purpose of these 3 instructions. Can
> anyone explain me about them? I didn't observe these 3 instructions
> when I compiled the same code with '-m64' switch instead of '-m32'.
This is for aligning the stack to 16 bytes. IIRC, the x86 ABI on Linux
does not mandate a stack alignment greater than 4 bytes (or 8 -- not
sure about the exact number), whereas the one for x86_64 does.