Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline assembly broken in IAR 5.5x #4

Open
ransford opened this issue Jan 24, 2013 · 7 comments
Open

Inline assembly broken in IAR 5.5x #4

ransford opened this issue Jan 24, 2013 · 7 comments

Comments

@ransford
Copy link
Member

For the 5.5x and later versions of their compiler, IAR changed the rules for inline assembly such that you can no longer do things like this:

asm("foobar:");
asm("MOV R1, R2");
asm("JMP foobar");

You get an error message like

unknown symbol in inline assembly

The fix will be to tidy up the parts of the WISP firmware that have asm statements referencing labels created in other asm statements. Where possible, collapse runs of asm statements into one. The above would become:

    asm volatile ("foobar\n\t" // oh yeah, and use volatile
                  "MOV R1, R2\n\t"
                  "JMP foobar");
@ransford
Copy link
Member Author

I've tested a patch that is backward compatible with IAR 5.4x and will merge it shortly.

@ransford
Copy link
Member Author

The patch for IAR 5.5x is ready; check out the iar550 branch. I'm trying to get someone to test that branch against IAR 5.4x; then I'll merge the patch into master.

@impedimentToProgress
Copy link

I got an error with both the volatile keyword and the label using the kickstarter version of IAR (5.52).

@ransford
Copy link
Member Author

@impedimentToProgress Can you be more specific about what you did and what happened?

@impedimentToProgress
Copy link

For simplicity I added your code to the blinky LED example that comes with IAR and attepmted to compile it. Here are the error messages when I leave in the volatile keyword,

msp430x2xx_fet_1.c
Error[Pe125]: expected a "(" C:\Users\Matt\Desktop\430\examples\examples\Flashing the LED\Flashing the LED\msp430x2xx\C-source\msp430x2xx_fet_1.c 31
Error while running C/C++ Compiler

Done. 1 error(s), 0 warning(s)

Here is the error message that I get when I remove the volatile keyword, but leave the rest of the code intact,

msp430x2xx_fet_1.c
Error[Og005]: Unknown symbol in inline assembly: "foobar" C:\Users\Matt\Desktop\430\examples\examples\Flashing the LED\Flashing the LED\msp430x2xx\C-source\msp430x2xx_fet_1.c 31
Error[Og006]: Syntax error in inline assembly: "Error[54]: Expression can not be forward" C:\Users\Matt\Desktop\430\examples\examples\Flashing the LED\Flashing the LED\msp430x2xx\C-source\msp430x2xx_fet_1.c 31
Error[Og005]: Unknown symbol in inline assembly: "foobar" C:\Users\Matt\Desktop\430\examples\examples\Flashing the LED\Flashing the LED\msp430x2xx\C-source\msp430x2xx_fet_1.c 33
Error[Og006]: Syntax error in inline assembly: "Error[54]: Expression can not be forward" C:\Users\Matt\Desktop\430\examples\examples\Flashing the LED\Flashing the LED\msp430x2xx\C-source\msp430x2xx_fet_1.c 33
Error while running C/C++ Compiler

Done. 4 error(s), 0 warning(s)

@impedimentToProgress
Copy link

This code compiles correctly,

asm(
"foobar:\n\t"
"MOV R1, R2\n\t"
"JMP foobar"
);

Note the addition of the colon. Volatile still causes an error. Also not that if we wanted to have code before the label, we would have to make sure the label is on the left margin:

asm(
"ADD R1, R2 \n"
"foobar: \n\t"
"MOV R1, R2 \n\t"
"JMP foobar"
);

or else IAR doesn't recognize it as a label.

@ransford
Copy link
Member Author

Thanks for those extra details. You are right that volatile is a no-no and that labels need special formatting (left justification and trailing colon); my original suggestion in the first comment was incorrect.

I am about to merge the iar550 branch into master; it already incorporates these corrections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants