On Tuesday, July 15, 2014 7:59:18 PM UTC-4, Frank Buss wrote:
> When I use assembler functions from my C code with cc65, what are the
> rules for the registers? I couldn't find it in the documentation.
>
I admit that I'm not totally knowledgeable about the matter, but I think cc65 would save the regbank whenever it calls another function from one that uses registers. I also think that, other than the sp and A/X, it doesn't need most things to be saved. Also, if a function doesn't return anything, I think cc65 ignores A/X. Anyway, I've been mostly successful in writing assembler with cc65 C code.
> Is there a difference between fastcall and normal defined functions with
> and without parameters?
>
The only difference of which I know is that, in fastcall, the last parameter is kept in A/X.
> - only one char parameter for A in a fastcall function, do I need to
> save X and Y?
>
Y doesn't matter, but I keep seeing assembler functions in system libraries set X to 0 when returning a char.
> - a fastcall function without parameters and void return, do I need to
> save the registers?
>
You shouldn't, but I don't see a difference in this case between default declaration and fastcall declaration. BTW, can anybody tell me the difference between fastcall and __fastcall__? The docs were a little confusing. :(