我想在uVision中使用STM32F进行简单的内联汇编实验,如以下代码所示。
但是当我编译它时,我遇到了一些错误信息。
unsigned int bar(unsigned int r0)
{
unsigned int r1;
unsigned int r4 = 1234;
__asm
{
MOVS r0,#0
LDR r1,[r0] ; Get initial MSP value
MOV SP, r1
LDR r1,[r0, #4] ; Get initial PC value
BX r1
}
return(r1);
}
我在编译时遇到以下错误消息。
*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'STM32F429_439xx'
compiling main.c...
../main.c(79): error: #3061: unrecognized instruction opcode
LDR r1,[r0] ; Get initial MSP value
../main.c(80): error: #20: identifier "SP" is undefined
MOV SP, r1
../main.c(81): error: #3061: unrecognized instruction opcode
LDR r1,[r0, #4] ; Get initial PC value
../main.c(82): error: #1084: This instruction not permitted in inline assembler
BX r1
../main.c(71): warning: #177-D: variable "r4" was declared but never referenced
unsigned int r4 = 1234;
../main.c(82): error: #114: label "r1" was referenced but not defined
BX r1
../main.c: 1 warning, 5 errors
"STM32F429_439xx\STM32F429_439xx.axf" - 5 Error(s), 1 Warning(s).
Target not created.
Build Time Elapsed: 00:00:01
我该怎么做才能解决这个问题?