Parameters and Registers
C51参数传递规则。
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
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
C51: HOW ARE FUNCTION PARAMETERS HANDLED?
通过 Cx51 User’s Guide: Parameters and Registers.
Posted by Ian at 10:55 Tagged with: parameter
本文详细介绍了C51编译器在MCU寄存器中传递参数的规则,包括参数传递机制如何显著提高系统性能,以及如何通过REGPARMS和NOREGPARMS指令控制参数传递。
6439





