Newbie doubts about stack !
Hello All !
I wrote the following C program and
obtained its assembly version , using command :
cc -S temp.c
< on an x-86 Linux machine >
/* File Name - temp.c */
void function(int a, int b, int c) {
char buffer[SIZE]; -------------------> SIZE=51
}
void main() {
function(1,2,3);
}
The Assembly File is as below :-
.file "temp.c"
.version "01.01"
gcc2_compiled.:
.text
.align 4
.globl function
.type function,@function
function:
pushl %ebp movl %esp, %ebp subl $72, %esp -----------> Stack allocation leave ret
.Lfe1:
.size function,.Lfe1-function
.align 4
.globl main
.type main,@function
main:
pushl %ebp movl %esp, %ebp subl $8, %esp subl $4, %esp pushl $3 pushl $2 pushl $1 call function addl $16, %esp leave ret .Lfe2: .size main,.Lfe2-main .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1
2.96-81)"
In the function part of the assembly file , I noticed that the depending on the "SIZE" of the array , it allocates memory on stack as shown in the below table .
Array Size Actual stack allocation
0 - 4 = 4
5 - 16 = 24
17 - 32 = 40
33 - 48 = 56
49 - 64 = 72Can anybody please explain me , what is the reason behind this ?
Why is it that only the required amount of stack is not allocated ?
Harmony !
________________________________________________________________________
Missed your favourite TV serial last night? Try the new, Yahoo! TV.
visit http://in.tv.yahoo.com
On Sun, 15 Sep 2002 11:47:51 +0100 (BST)
Anticipating a Reply <[email protected]> wrote:
you'd probably better get familiar with your "C" compiler and try understandig it's purpose. document which compares "C"-ish data structures to assembly available via
http://www.lxhp.in-berlin.de/linux-asm.ps.gz
Quoted 92 lines
Hello All !
I wrote the following C program and
obtained its assembly version , using command :cc -S
temp.c< on an x-86 Linux machine >
/* File Name -
temp.c*/void
function(int a, int b, int c){
char buffer[SIZE]; -------------------> SIZE=51
}void
main(){
function(1,2,3);
}The Assembly File is as below :-
.file "
temp.c".version "01.01"
gcc2_compiled.:
.text
.align 4
.globl function
.type function,@function
function:pushl %ebp movl %esp, %ebp subl $72, %esp -----------> Stack allocation leave ret.Lfe1:
.size function,.Lfe1-function
.align 4
.globl main
.type main,@function
main:pushl %ebp movl %esp, %ebp subl $8, %esp subl $4, %esp pushl $3 pushl $2 pushl $1 call function addl $16, %esp leave ret .Lfe2: .size main,.Lfe2-main .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.12.96-81)"
In the function part of the assembly
file , I noticed that the depending on
the "SIZE" of the array , it allocates
memory on stack as shown in the below
table .Array Size Actual stack allocation
0 - 4 = 4 5 - 16 = 24 17 - 32 = 40 33 - 48 = 56 49 - 64 = 72Can anybody please explain me ,
what is the reason behind this ?Why is it that only the required
amount of stack is not allocated ?Harmony !
________________________________________________________________________
Missed your favourite TV serial last night? Try the new, Yahoo! TV.
visit http://in.tv.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de
software patents http://petition.eurolinux.org/pr/pr17.html
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlHello !
The link sent by you is dead .
Can you please send me the document ,
if you have it .
Thank you .
Harmony !
--- hp <[email protected]> wrote: > On Sun, 15
Sep 2002 11:47:51 +0100 (BST)
Quoted 68 lines
Anticipating a Reply <[email protected]> wrote:
you'd probably better get familiar with your "C"
compiler and
try understandig it's purpose. document which
compares "C"-ish
data structures to assembly available viahttp://www.lxhp.in-berlin.de/linux-asm.ps.gz
Quoted 6 lines
Hello All !
I wrote the following C program and
obtained its assembly version , using command :Quoted 8 lines
cc -S
temp.c< on an x-86 Linux machine >
/* File Name -
temp.c*/void
function(int a, int b, int c){
char buffer[SIZE]; ------------------->SIZE=51
Quoted 29 lines
}
void
main(){
function(1,2,3);
}The Assembly File is as below :-
.file "
temp.c".version "01.01"
gcc2_compiled.:
.text
.align 4
.globl function
.type function,@function
function:pushl %ebp movl %esp, %ebp subl $72, %esp -----------> Stack allocation leave ret.Lfe1:
.size function,.Lfe1-function
.align 4
.globl main
.type main,@function
main:Quoted 14 lines
pushl %ebp movl %esp, %ebp subl $8, %esp subl $4, %esp pushl $3 pushl $2 pushl $1 call function addl $16, %esp leave ret .Lfe2: .size main,.Lfe2-main .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux
Quoted 31 lines
7.1
Quoted 29 lines
2.96-81)"
In the function part of the assembly
file , I noticed that the depending on
the "SIZE" of the array , it allocates
memory on stack as shown in the below
table .Array Size Actual stack allocation
0 - 4 = 4 5 - 16 = 24 17 - 32 = 40 33 - 48 = 56 49 - 64 = 72Can anybody please explain me ,
what is the reason behind this ?Why is it that only the required
amount of stack is not allocated ?Harmony !
________________________________________________________________________
Quoted 15 lines
Quoted 1 line
Missed your favourite TV serial last night? Try
the new, Yahoo! TV.
Quoted 3 lines
visit http://in.tv.yahoo.com
-
To unsubscribe from this list: send the line"unsubscribe linux-assembly" in
Quoted 2 lines
the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de software patents
http://petition.eurolinux.org/pr/pr17.html
________________________________________________________________________
Missed your favourite TV serial last night? Try the new, Yahoo! TV.
visit http://in.tv.yahoo.com