Could somebody tell me please how can I execute inline assembly code in C code using TI code composer studio (for ARM)?
I searched and tried but nothing worked.
For example, when I try this very simple code:
asm("push r0\n");
or this
__asm("push r0\n");
I always get:
[E0002] Illegal mnemonic specified push r0
1 Assembly Error, No Assembly Warnings
I read something says that my previous code is GCC style,and TI compiler doesn't accept it!. Then how can I execute my own inline assembly codes?
Finally I found the solution!!
the main problem will be solved by adding a space or tab before the assembly instruction like this:
asm(" MOVS R0, #5\n");
This won't work:
asm("MOVS R0, #5\n");
And in push we have to put the register in braces {R0}
asm(" PUSH {R0}\n");
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With