Keil™, An ARM® Company

Cx51 User's Guide

Parameters and Registers

The Cx51 Compiler passes up to three function arguments in MCU registers. This mechanism significantly improves system performance as arguments are not written to and read from memory. Argument or parameter passing can be controlled by the REGPARMS and NOREGPARMS directives.

The following table details the registers used for different argument positions and data types.

Argument
Number
char
1-byte ptr
int
2-byte ptr
long
float
generic ptr
1R7R6 & R7R4-R7R1-R3
2R5R4 & R5R4-R7R1-R3
3R3R2 & R3 R1-R3

Note

  • If the first parameter of a function is a bit type, then other parameters are not passed in registers. This is because parameters that are passed in registers are out of sequence with the numbering scheme shown above. For this reason, bit parameters should be declared at the end of the argument list.
  • If no registers are available for argument passing, fixed memory locations are used for function parameters.

Related Knowledgebase Articles