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.

TMS320F280049: Embed assembly in C/CLA and call assembly from C/CLA

Part Number: TMS320F280049

Dear Champs,

I am asking this for our customer.

The user wants to write assembly in the same C/CLA files and call from C/CLA and need us to clarify.

1. Assembly embedded in the same C file

We should be able to use this kind of statement directly in C codes, right?

asm(" EALLOW");

But can the user also use directives directly?

For example, this is a code from one of our competitor to declare a variable or a constant.

__asm__ volatile (".EQU MAX_FREQUENCY, 22000"); // 220 KHZ

Can we use asm("..."); to do all the assembly codes including all the directives?

If not, what is the limitation or concern?

2.  Assembly embedded in the same CLA file

Same as (1) above, does it also work in .cla file for CLA?

3. Call assembly from C

If the user uses a function instead and call it from an .asm file, how do they do?

Do we have any example and doc to show this?

4. Call assembly from CLA.

Same as (3) above, how does the user do from .cla file on CLA?

Wayne Huang

  • Hi Wayne,

    Please see the Assembly Language Tools Guide: This has all the necessary information for your questions above.

    https://www.ti.com/lit/spru513

    Here is a link to Compiler Optimizing Guide in case there is some information you can refer from here

    https://www.ti.com/lit/spru514

    Thanks,
    Ashwini

  • Dear Ashwini,

    We are aware of these two doc, but it seems there is too much information in the doc for us to find out the solutions.

    Would you please explicitly which sections we can refer to first for the above questions?

    Wayne Huang

  • We should be able to use this kind of statement directly in C codes, right?

    asm(" EALLOW");

    You can.  However, in this specific case, there is a compiler intrinsic.  Please search the C28x compiler manual for the sub-chapter titled Using Intrinsics to Access Assembly Language Statements.  Notice the intrinsic __eallow.  An intrinsic like this is always better than an asm statement.

    But can the user also use directives directly?

    It depends.  The contents of an asm statement are limited.  Please search the C28x compiler manual for the sub-chapter titled The __asm Statement.  

    If the user uses a function instead and call it from an .asm file, how do they do?

    Please search the C28x compiler manual for the sub-chapter titled Interfacing C and C++ With Assembly Language. This documentation applies to C28x and CLA code.  My advice is to start with very small, very simple, but complete programs.  Use these small programs just to learn how it works.  Then slowly scale it up to your full program.

    Thanks and regards,

    -George