Mail Archives: djgpp/2001/06/27/13:45:14
ZMAN wrote:
> int main ()
> {
> int i;
> i = 0x12345678;
> }
> 00000000 55 push ebp
> 00000001 89E5 mov ebp,esp
> 00000003 83EC04 sub esp,byte +0x18
> 00000006 C745FC78563412 mov dword [ebp-0x4],0x12345678
> 0000000D C9 leave
> 0000000E C3 ret
>
> The third line reserves 18 bytes.
Does it? First of all, its 0x18 bytes, aka 24 bytes.
Are you sure it isn't just padding for alignment?
If I add yet another int, the number doesn't increase...
<CODE>
int main ()
{
int i;
i = 0x12345678;
int j;
j = 0xCAFEBABE;
}
</CODE>
<ASM>
0x80483c0 <main>: push %ebp
0x80483c1 <main+1>: mov %esp,%ebp
0x80483c3 <main+3>: sub $0x18,%esp
0x80483c6 <main+6>: movl $0x12345678,0xfffffffc(%ebp)
0x80483cd <main+13>: movl $0xcafebabe,0xfffffff8(%ebp)
0x80483d4 <main+20>: xor %e
</ASM>
I'm using G++ 2.95.2 on Red Hat Linux, disassembling with GDB.
I can go up to 4 ints, and still the 0x18 doesn't change.
On the fifth int, I get 0x28. On the ninth int, I get 0x38.
See a pattern?
> And it should reserve 4 bytes because thats the size of an int right?
Is it? Thats platform dependant according to the C++ standard.
And with that, I believe this question is off-topic for comp.lang.c++
(and c.l.c too) so I set FUT to comp.os.msdos.djgpp.
--
<[ Kent Dahl ]>================<[ http://www.stud.ntnu.no/~kentda/ ]>
)____(stud.techn.;ind.øk.data)||(softwareDeveloper.at(Trustix))_(
/"Opinions expressed are mine and not those of my Employer, "\
( "the University, my girlfriend, stray cats, banana fruitflies, " )
\"nor the frontal lobe of my left cerebral hemisphere. "/
- Raw text -