This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc-4.9.2: Assembly for i386 Target


On Mon, Oct 12, 2015 at 11:11 AM, Abhishek Aggarwal
<abhiinnitald@gmail.com> wrote:
> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]