[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] calling conventions



[Thomas]

I'm sorry but Delphi and Kylix mix register and stack parameters in their
calling convention and all work OK without any problems. It's a very
speed call system and simple to use.

[I]

C only,

Write your prototype :

int open (char const *,int,...);
    ==> r1 open (r1,r2,stack);

Now write your implementation :

int open (char const *,int,int) { }
    ==> r1 open (r1,r2,r3)

And now, try to call 'open' with the third argument :

... = open ("...",...,...);
    ==> BANG !!!!!

Why ? because your header use "r1 open (r1,r2,stack)" but finally you will get
the call address of "r1 open (r1,r2,r3)". So your implementation is unable to
handle the third argument since it is in the stack and not in r3.

Delphi and Kylix, when you use pascal functions, uses their fast calling
convention because they don't need to be compatible with other languages. If
they want to call C functions, they just took the C calling convention (for
IA32, all parameters in stack) especially if they want to access glibc or
likes.



*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/