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.

how to write an asm code to response with volatile variable change



Hi, I am writing an asm code for C6748 processor, and I would like to know if it is possible for the asm code to response immediate with the change of its variable. The feature I am developing is to let the asm to abort its operation whenever the abort flag that (volatile bool) is passed into the asm function has being set to non zero. Thank you.

  • Please explain more about what you want to do. Your required operation is not clear to me.

    It is always best to write functions in C and use the C optimizer to improve performance. Only move to assembly programming if the performance is not fast enough for your application.

    C6000 assembly is very difficult to learn and to write. This is why we put so much effort into the C compiler.

    Regards,
    RandyP

  • If I understand correctly, the question you are asking is if the assembler can automatically abort based on the the value of a variable.  If this is the question, the answer is no.  If a variable changes, the code will do nothing different.  You would have to execute some code to actually read that variable and then take action on it.  Variable writes don't behave like interrupts.

    Even with the C compiler, you won't be able to do this.  

    There are other ways that you could do similar things.  You could create a periodic interrupt that will cause the value of the variable to be checked and take action if it has changed.  You could periodically check within the assembly language function.  

    What potentially has the ability to change the flag?  In many cases, this is a peripheral.  The way a peripheral would handle this would be to send an interrupt signal.  

    Additionally, I'll add, that I agree with Randy.  There isn't much that you can do with hand coded assembly that you can't accomplish nearly as efficiently with the C Compiler.  And the development headaches will be significantly reduced.  (You're seeing this first hand with the issue that you reported in your other thread.  If you are not getting similar results with the compiler as you are with hand coding, then I would suppose that the code is not being optimized as well as it potentially could be.  I'd encourage you to take a look at the C6000 optimization Workshop http://processors.wiki.ti.com/index.php/TMS320C6000_DSP_Optimization_Workshop.  The more you can let the compiler know about your C code, the better it can optimize it.  I can't stress how much easier it is to learn the details of the compiler/optimizer than it is to learn and remember all of the rules associated with the C6000 Architecture and instruction set.   

    Regards,

    Dan