|
From: Benjamin K. <bk...@we...> - 2002-01-10 01:02:21
|
As I read, there is no standard for fastcall calling convention: "There is no standard for "fastcall" and several compilers support it (including those by Borland) but everybody gives their own to the concept. For example, MicroSoft uses two registers (ECX and EDX) and Borland uses three registers (EAX, EDX and ECX). MicroSoft passes register-parameters left-to-right and stack-parameters right-to-left and Borland passes all of them left-to-right. etc. etc." This is MS Definition: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HT ML/_core___fastcall.asp But Borland's one is much better I think. >> I think the advantage is that all arguments passed to function via cpu >> register. This is faster than accessing the stack. But mingw's >> implementation is a real joke, it's slower than using cdecl convention. >>The other point is, the fastcall implementation in mingw is wrong. >Use the '-O3' option with gcc and you will see some nice assembler code >without any 'bells and whistles'. No, there are some more errors if I use -O1..x switch. Every call within function main() will be thrown away: int main() { MyFunc(1,2,3,4); MyFunc2(1,2,3,4); MyFunc3(1,2,3,4); } But assembler will produce: _main: pushl %ebp movl %esp,%ebp subl $8,%esp call ___main movl %ebp,%esp popl %ebp ret Where are the call's MyFunc, MyFunc2 ... ? rg Benjamin Kalytta |