This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using Inline functions in C code

Hi all,

 

1.   I have a code with some inline functions written with cortex-A8 assembly instructions and arm instructions. With in that I used __inline keyword to define the function and written statements with asm("instruction op1, op2, op3"); using optimisation level 3 and required options which works fine for all other code.

with this above mentioned syntax and options I compiled the code, It shown error in console saying that invalid mnemonic specified.  ERROR: D:\Document and settings\data\localsettings\temp\6\3400021..

ex: invalid mnemonic specified

      mov r0, r1

so any one can help in this regard to solve this?

2.  can any one tell me the example of writting the inline function with syntax to work on my code.

__inline sample(int i, int j)

{

      asm("MOV i, j");

      return i;

}

->

 3. can i use directly C variables along with asm statements?

is there need of any other option to mention along while using inline statements?

for this i followed the given TMS470 c/c++ compiler and assembler guides. there i followed with some inline function topic.

 

Thanks,

Vinay.

  • Vi Vinay,

    I have never done exactly what you are doing, so I'm not sure if you can use C variables in inline assembly statements.  But since you are passing in the variables to a function, can you use r0 and r1 instead of i and j?   Relying on the C protocol for passing parameters into function, you should be able to know r0 will contain i and r1 will contain j. Please let me know if you issue is resolved, or I will look into it further.

    Addtionally, have you looked into using a C macro instead of an inline assembly for such a simple function?

    Regards,

     

  • Hi Jeff L,

    I have tried with some changes in sample program and the error i have mentioned in case 1 has removed.

    changes are

    asm(" MOV r0, #2");

    the error is caused by with out mentioning space after the " (before MOV).

    now registers are working with instructions and for variables it is causing error again invalid mnemonic specified.

    asm(" MOV i, #2");

    even iam passing to the function arguments like

    __inline sample( int i)

    {

    statement;

    }

    If i directly takes the arguments to registers the variable values are not updating and i value contains zero when i print that in function.

    here iam just mentioning the mov instruction case but the problem is wtih all other instructons to use variables.

     

    so give me  a suggestion to write the correct syntax in order to read values from variables and passing from function.

    if only one asm statement i used with asm() then also to use the C variables.

     

    Thanks,

    Vinay.

     

     

  • Hi Vinay,

    Sorry for the delay.  I'm not able to resolve your issue, so I'm going to have it moved over to the compiler forum to get your issue resolved.

    Regards,

  • Hi Jeff L ,

    I didn't get the answer from compiler forum for this post, do i need to post these question there to get the answer for this issue..

     

    Thanks,

    Vinay.