问题描述
我试图使用了德州仪器的Stellaris Cortex-M3的。我的工作环境是IAR。有很多的小的改动,以适应IAR和具体的uC我使用,但我有一个,我似乎无法来解决......坦白说有点在我头上。
I am attempting to use BeRTOS for a Texas Instruments Stellaris Cortex-M3. My work environment is IAR. There were a lot of minor changes to accommodate IAR and the specific uC that I am using but I've got one that I can't seem to solve... and frankly it's a bit over my head.
code的该位:
1 void NAKED lm3s_busyWait(unsigned long iterations)
2 {
3 register uint32_t __n __asm("r0") = iterations;
4
5 __asm volatile (
6 "1: subs r0, #1\n\t"
7 "bne 1b\n\t"
8 "bx lr\n\t"
9 : : "r"(__n) : "memory", "cc");
10
11 }
...正在产生一些错误和警告。
... is generating a few errors and warnings.
错误:预期; -----> 3号线
错误:预期(-----> 5号线
Error: expected a "(" -----> Line 5
错误:预期)-----> 9号线
Error: expected a ")" -----> Line 9
警告:变量__N被宣布但从未引用-----> 3号线
Warning: variable "__n" was declared but never referenced -----> Line 3
有什么建议?
推荐答案
我是pretty确保IAR的编译器不支持内联汇编;至少我一直使用使用IAR的工具时,每当我需要在这一水平做事实际独立的汇编语言源文件。 罢工>
在code你张贴看起来或多或少等同于以下C code:
The code you posted looks like it's more or less equivalent to the following C code:
void lm3s_busyWait( unsigned long iterations)
{
register volatile unsigned long n = iterations;
while (--n) {
/* do nothing */
}
}
您可能能够使用代替你的版本,但它会有点慢。这是否重要与否取决于你使用它的东西。编译器一般不会将挥发性
在寄存器中,那么这一翻译递减寄存器,功能很可能会创下的存储空间。
You might be able to use that in place of your version, but it'll be somewhat slower. Whether that matters or not depends on what you're using it for. Compilers generally won't place a volatile
in a register, so intead of decrementing a register, the function would likely be hitting a memory location.
下面是一个小的ARM汇编函数,你可以放入一个文件名为 lm3s_busyWait.s
并将其添加到您的IAR项目。它应该是完全等同于你使用GCC的内联汇编的版本:
The following is a small ARM assembly function that you can put into a file named lm3s_busyWait.s
and add it to your IAR project. It should be exactly equivalent to the version you have using GCC's inline assembly:
/* C prototype:
*
* void lm3s_busyWait( unsigned long iterations);
*
*/
PUBLIC lm3s_busyWait
SECTION .text:CODE:NOROOT(4)
THUMB
lm3s_busyWait:
subs r0, #1
bne lm3s_busyWait
bx lr
end
这篇关于GCC内联大会IAR嵌入式大会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!