From: Andrew Crabtree Message-Id: <199708052045.AA170553953@typhoon.rose.hp.com> Subject: Re: Help with using Nasm To: Georg DOT Kolling AT t-online DOT de (Georg Kolling) Date: Tue, 05 Aug 1997 13:45:53 PDT Cc: djgpp AT delorie DOT com In-Reply-To: ; from "Georg Kolling" at Aug 5, 97 10:10 pm Precedence: bulk > > 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