C51 allows up to three function arguments to be passed in CPU registers. This mechanism significantly improves system performance as arguments do not have to be written to and read from memory. Argument or parameter passing can be controlled by the REGPARMS and NOREGPARMS control directives defined in the previous chapter.
The following table details the registers used for different argument positions and data types.
Argument |
char, |
int, |
long, |
untyped |
1 |
R7 |
R6 & R7 |
R4 - R7 |
R1 - R3 |
2 |
R5 |
R4 & R5 |
R4 - R7 |
R1 - R3 |
3 |
R3 |
R2 & R3 |
R1 - R3 |
|
If no registers are available for argument passing, fixed memory locations are used for function parameters.