C51 Parameters and Registers

本文详细介绍了C51编译器在MCU寄存器中传递参数的规则,包括参数传递机制如何显著提高系统性能,以及如何通过REGPARMS和NOREGPARMS指令控制参数传递。
 
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
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值