Mail Archives: djgpp/1997/08/05/16:46:19
>
> I really don't know why esp is copied to ebp (at least NASM's example code does
> so).
Because that is basically how the ENTER and LEAVE commands work, that is how
gcc does it, and it aids in debugging. Its called a stack frame. Things like
symify and gdb's backtrace wouldn't work without it.
>But it does matter what type of parm it is!
Not for the ones you listed it doesn't. Even on the old 8088 there was no way to push
a byte onto the stack. Notice in the assembly below that a dword got pushed each time.
> for example: c prototype void xxx (char a, short b, long c)
> a = BYTE [esp + 4]
> b = WORD [esp + 5]
^^^^ 8
> c = DWORD [esp + 7]
^^^ 12
----------------------------------------
extern void foo(char a, short b, long c);
foo2(void)
{
foo(5,10,15);
}
------------------------------------------
gcc -o - -S test.c
foo2:
pushl %ebp
movl %esp,%ebp
pushl $15
pushl $10
pushl $5
call _foo
addl $12, %esp
L1:
movl %ebp,%esp
popl %ebp
ret
- Raw text -