The __fastcall convention specifies that arguments to functions are to be passed in registers, when possible. The following list shows the implementation of this calling convention:
Element | Implementation |
Argument-passing order | Left to right |
Argument-passing convention | By value, unless a pointer or reference type is passed |
Stack-maintenance responsibility | Called function adjusts the stack |
Name-decoration convention | At sign (@) is prefixed to names |
Case-translation convention | No case translation performed |
Return-value conventions | Identical to __cdecl |
To declare a function as __fastcall, use a declaration of the form:
char * __fastcall parsechar( char *szString, char chTarget );
Note that, in the preceding declaration, the modifier __fastcall modifies the name immediately to its right, parsechar.
The compiler allocates registers for the arguments according to the type of the argument and availability of an appropriate register. If no appropriate register is available, the argument is pushed on the stack, much as in the __pascal calling convention. The following list shows the register candidates for various types:
Type | Register Candidate |
char, unsigned char | AL, DL, BL |
int, unsigned int | AX, DX, BX |
long, unsigned long | DX:AX |
“pointer to near” | BX, AX, DX |
“pointer to far,” “pointer to huge” | Passed on the stack |
All far and huge pointers, structures, unions, and floating types are passed on the stack.