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 "ASM" INSIDE A C-CODE



Hello,

I f I want to insert assembly instructions inside a C code by "asm" instruction and then if I want to use the processor registers, do I need to store the old values of those registers into stack by my code or in that case the compiler would store them at the beginning and restore them at the end of that assembly part by inserting store and load instructions automatically? I am using C6472 processor with code composer studio V4.

 

Regards,

AC.

 

  • AC,

    The fact that you ask this question tells me two things:

    1. You are smart enough to recognize that there could be problems.

    2. You should not be inserting "asm" instructions in your C code.

    Your choices, in order of my opinion of how good the idea is:

    a - Find a way to do what you want in C code.

    b - Use intrinsics to get access to specific instructions that the compiler might not use.

    c - Write an assembly function that is compatible with C, and call that function from C. The compiler User's Guide specifies how registers are handled in this case.

    d - Write the code without the "asm" and save the listing file, then write it with the "asm" and compare the new listing file with the old one. That will tell you exactly what compiler does with registers around the "asm", which is probably nothing. It might also show you that the compiler changes registers from one compilation to the next. Please refer back to advice #2 above.

    Regards,
    RandyP

     

    If this does not answer your question, please tell us more. If it does, please click the  Verify Answer  button below.