hi,
I wrote a simple c function:
void function(){
int n;
char s[6];
n = 1;
s[0] = 2;
s[5] = 3;
}
This disassembles to:
pushl %ebp
movl %esp, %ebp
sub $40, %esp
movl $1, -12(%esp)
movb $2, -40(%esp)
movb $3, -35($esp)
leave
ret
I am trying to understand why the char[] is given the address that starts at -40.
it is a 6 byte array, so I would think that it would require 8 bytes (multiple of 4-byte word), in which case it would be assigned to the memory address -20(%esp)
Why -40(%esp)?
Thanks
EDIT: I am also under the assumption that n is given the offset of -12(%esp) because ints and registers are 4 bytes, and eip is pushed to -4(%esp) and ebp is pushed to -8(%esp). Is this correct?
Thank you in advance!!