|
| Parameters and RegistersThe 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 |
|---|
| 1 | R7 | R6 & R7 | R4-R7 | R1-R3 | | 2 | R5 | R4 & R5 | R4-R7 | R1-R3 | | 3 | R3 | R2 & 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 |
|