Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline assembly in C code using TI code composer studio (for ARM)

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?

like image 776
Mohammed Noureldin Avatar asked Jul 04 '15 09:07

Mohammed Noureldin


1 Answers

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.

like image 77
Mohammed Noureldin Avatar answered Sep 22 '22 18:09

Mohammed Noureldin