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.

inline assembly



Hello all,

                  below is a small snippet of the c file with the assembly code embedde in it.

Can anyone let us know how to use the C variables in the inline assemby.

void main()

{

short temp1, temp2, var;

temp1 = 10;

temp2 = 20;

 

asm(" .global _temp1");

asm(" .global _temp2");

asm(" .global _Var1");

 

asm(" MPY .M1 _temp1, _temp2, _Var1");

 

printf("%d is the product \n", var1);

}

assembler throws and error informing that the operands are not legal registers

anything without the C variables like the bleow is working fine..

MPY .M1 A4,A6,A9

thanks and regards

  • Inline assembly does not use the C variables as you have observed.  Inline assembly can only operate on things like registers of the CPU, etc.
    For the functionality you are looking for, I would suggest using intrinsic functions.  This will give you more control over the operations used, but can utilize C variables, etc.

    You can find information about the intrinsic funtions in the TMS320C6000 Optimizing Compiler v6.1 User's Guide (SPRU187) in Section 7.5.4

  • Hello BrandonAzbell,

                                          Thanks for the reply. I have been using GCC for some time. it supports inline asm too. the syntax there would be something like

    asm volatile ("....asm instruction": i/p operands: o/p operands); wherein i can specify the c variables in the input parameter and output parameters.

    Also i saw the below link in the community. In the post mentioned below, the reply to the main question posted, you can notice that a c variable is being used in the inline asm.

    http://community.ti.com/forums/p/4558/16850.aspx#16850

    hence we were trying in a similar manner. where could we find more information and samples for inline assembly programming,

     

    thanks and regards

  • Yes, you are correct regarding the ability to access labels.

    However, generally speaking, the intrinsics are a little easier to deal with.

    prasanna um said:

    where could we find more information and samples for inline assembly programming,

     

    The document I cited above is a resource for inline assembly.  However, you will need to understand the instruction set architecture as well, which is documented in one of the 3 documents below, depending on the architecture you are targeting.

    • SPRU731—TMS320C62x DSP CPU and Instruction Set Reference Guide

    • SPRU732—TMS320C64x/C64x+ DSP CPU and Instruction Set Reference Guide

    • SPRU733—TMS320C67x/C67x+ DSP CPU and Instruction Set Reference Guide