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.
This bit of 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.
Error: expected a ";" -----> Line 3
Error: expected a "(" -----> Line 5
Error: expected a ")" -----> Line 9
Warning: variable "__n" was declared but never referenced -----> Line 3
Any suggestions?
I'm pretty sure that IAR's compiler doesn't support inline assembly; at least I've always used an actual separate assembly language source file whenever I've need to do things at that level when using IAR's tools.The code you posted looks like it's more or less equivalent to the following C code:
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.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: