Hi all,
I tried compiling the above two programs :
on x86, 32 bit machines.

And when I used objdump on that I saw the following code.
Can anyone help me know,
Why in the objdump of our first program the esp is decremented by 18H bytes
and in the second program the esp is decremented by 28H bytes.

How actually is teh memory allocated by gcc for local variables.

Kindly help.

int main()
{
 char x;
 return 0;

}


[EMAIL PROTECTED] ~]# gcc test.c
[EMAIL PROTECTED] ~]# objdump -S a.out | less
08048348 <main>:
8048348:       55                          push   %ebp
8048349:       89 e5                    mov    %esp,%ebp
804834b:       83 ec 18               sub    $0x18,%esp
804834e:       83 e4 f0                and    $0xfffffff0,%esp
8048351:       b8 00 00 00 00   mov    $0x0,%eax
8048356:       83 c0 0f                add    $0xf,%eax
8048359:       83 c0 0f                add    $0xf,%eax
804835c:       c1 e8 04               shr    $0x4,%eax
804835f:       c1 e0 04                shl    $0x4,%eax
8048362:       29 c4                    sub    %eax,%esp
8048364:       b8 00 00 00 00    mov    $0x0,%eax
8048369:       c9                      leave
804836a:       c3                      ret
804836b:       90                      nop

int main()
{
 double x,y,z;
 char p,q,r;
 return 0;

}

08048348 <main>:
8048348:       55                      push   %ebp
8048349:       89 e5                   mov    %esp,%ebp
804834b:       83 ec 28                sub    $0x28,%esp
804834e:       83 e4 f0                and    $0xfffffff0,%esp
8048351:       b8 00 00 00 00          mov    $0x0,%eax
8048356:       83 c0 0f                add    $0xf,%eax
8048359:       83 c0 0f                add    $0xf,%eax
804835c:       c1 e8 04                shr    $0x4,%eax
804835f:       c1 e0 04                shl    $0x4,%eax
8048362:       29 c4                   sub    %eax,%esp
8048364:       b8 00 00 00 00          mov    $0x0,%eax
8048369:       c9                      leave
804836a:       c3                      ret
804836b:       90                      nop




--
Regards,
Sandeep





        
If the facts don't fit the theory, change the facts.

Reply via email to