tags:

views:

842

answers:

2

So i have a piece of assembly that needs to call a function with the fastcall calling convention on windows, but gcc doesn't (afaict) support it. GCC does provide the regparm attribute but that expects the first 3 parameters to be passed in eax, edx and ecx, whereas fastcall expects the first two parameters to be passed in ecx and edx.

I'm merely trying to avoid effectively duplicating a few code paths, so this isn't exactly critical, but it would be great if it were avoidable.

+1  A: 

If you're calling the function from asm then surely you have complete control over how you call the function. What's stopping you from just loading up the registers and issuing a CALL?

The problem is that the caller is in assembler, the function i'm calling is in C -- and it's the compilers' codegen for the function that i'm calling that is problematic :-(
olliej
Aaaah...yep, I assumed you were concerned with the caller not the callee.
No worries, i figured that was the confusion :D
olliej
+6  A: 

GCC does support fastcall, via __attribute__((fastcall)); it appears to have been introduced in 3.4.

ephemient