Re: Ways to fill the stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 9, 2013 at 7:41 PM,  <sztfg@xxxxxxxxx> wrote:
> In this function:
> void foo(void)
> {
>   const char a1[6] = {'t','e','s','t','1','2'};
>   bar(a1);
>   const char a2[6] = ("test12");
>   bar(a2);
>   return;
> }
> In case of bar(a1) it stores string in this way:
>         movb    $116, -16(%rbp)
>         movb    $101, -15(%rbp)
>         movb    $115, -14(%rbp)
>         movb    $116, -13(%rbp)
>         movb    $49, -12(%rbp)
>         movb    $50, -11(%rbp)
> But in case of bar(a2):
>         movl    $1953719668, -32(%rbp)
>         movw    $12849, -28(%rbp)
>         leaq    -32(%rbp), %rax
> Can somebody explain me this?

Bad optimization for a1, I guess.  We could do better.

> Why not use push instruction?

I don't see why this would ever use a push instruction.  Arguments are
passed in registers on x86_64.  For each call the local array is built
on the stack, then the address of the array is passed in a register.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux