内嵌汇编的错误
问题类别:ARM软件工具 > Keil MDK | 浏览次数:13398 |
发布日期:2012/4/23 17:33:09 | 文章来源:完美体育·(中国)手机网页版科技 |
回复日期:2020/12/20 9:52:07 |
环境说明
RealView MDK3.05以上分析描述
代码如下: int func (int val) { __asm { MOV R7,0xFFFF0000 MOV R0,R0,LSL #16 ADD R0,R0,R1 } return val; } 错误提示: warning: #1267-D: Implicit physical register R7 should be defined as a variable warning: #1267-D: Implicit physical register R0 should be defined as a variable error: #549: variable "R0" is used before its value is set warning: #1267-D: Implicit physical register R1 should be defined as a variable error: #549: variable "R1" is used before its value is set warning: #177-D: variable "val2" was declared but never referenced问题解答
问题解决:由于嵌套过程中会出现寄存器冲突
正确例程:
int func (int val) {
int val2;
__asm
{
MOV val2,0xFFFF0000
MOV val,val,LSL #16
}
return val+val2;
}