Re: C/C++ calling convention
- From: "Don Burn" <burn@xxxxxxxxxxxxxxxx>
- Date: Wed, 7 Jun 2006 08:51:50 -0400
First, beaware that _cdecl is one of several calling conventions. As to your
questions:
1. There is a stack pointer per thread
2. The called function stores the stack pointer in another register, then
references the arguments as an offset of the register
3. There is no popping, so the stack has to be cleaned up.
--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply
"Berger" <berger@xxxxxxxxxxx> wrote in message
news:uhp0Q6iiGHA.3496@xxxxxxxxxxxxxxxxxxxxxxx
A theoretical question: Sorry if its a beginner question.
Here is a quote from the MSDN explaning the C/C++ calling convention.. It
demonstrates that the calling function is responsible to clean the stack
pointer and it does it by the command "add esp,8" after returning from
the called function.
My questions:
1. Is the stack pointer common in a certain thread(or process)?
2. How does the called function get the parameters, is it by performing
twice pop functions?
3. If it pops twice why is there any need to clean the stack?
int _cdecl CFunc(int a, int b);
calling function called function
-------------------------------------------
push b _CFunc PROC NEAR
push a .
call _CFunc .
add esp,8 .
. RET
. _CFunc ENDP
.
int _cdecl CVarFunc(int a, ...);
Thanks for any refernce to my questions.
Berger
.
- Follow-Ups:
- Re: C/C++ calling convention
- From: Arkady Frenkel
- Re: C/C++ calling convention
- References:
- C/C++ calling convention
- From: Berger
- C/C++ calling convention
- Prev by Date: Re: The basics of Windows' messages
- Next by Date: C/C++ calling convention
- Previous by thread: C/C++ calling convention
- Next by thread: Re: C/C++ calling convention
- Index(es):
Relevant Pages
|