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.

Multiplies with assembly

Other Parts Discussed in Thread: TMS570LS20216, LM3S8971

Hello, experts:

        I am using TMS570LS20216 for the motor control development. I have a question like this:

       When I see the example code RDK-BLDC(9107) use LM3S8971 CPU which based on the Cortex-M3, there is a multiplies function(the function will be called by every milliseconds  interrupt) define like this

//
// For CCS implement this function in pure assembly.  This prevents the TI
// compiler from doing funny things with the optimizer.
//
#if defined(ccs)
long MainLongMul(long lX, long lY);
    __asm("    .sect \".text:MainLongMul\"\n"
          "    .clink\n"
          "    .thumbfunc MainLongMul\n"
          "    .thumb\n"
          "    .global MainLongMul\n"
          "MainLongMul:\n"
          "    smull   r0, r1, r0, r1\n"
          "    lsrs    r0, r0, #16\n"
          "    orr     r0, r0, r1, lsl #16\n"
          "    bx      lr\n");
#endif    

      My quesions are : can i use it directly on the TMS570LS20126 CPU which base on the Cortex-R4 without any change(i use CCS) ? If not, how to modify the asm code?

     Thank you!

  • Max,

    Thanks for using our forum.

    It is not easy to answer to your question. M3 is based on ARM V7M ISA and R4 is ARM V7R ISA.
    This 2 ISA are not 100% compatible.

    In this specific case, I don't see any issue and this code should compile with our Code Generation Tool.
    In the project properties (Processor Options) you have to select the correct Target Processor Version to "7R4" when your code is compiled for  TMS570LS20126.

    Please let me know if your code is working with this option.

    Best Regards,

    Jean-Marc

  • Hi, Jean:

         Thanks for your suggestion, i made a simple test on the TMS570LS20216 USB Kit with this function, and it seems working well, but i'm not sure it will affect my other code in the future.

        Thank you very much.

     

     

  • Max,

    There is another point I want to clarify. It is obvious but anyway.

    The programmers model between M3 and R4F is completely different in tern of exception (Reset, IRQ, FIQ) and stack management.
    This part of the code will have to be fully redone for R4F based micro controller.

    If I've answered your question, please mark this post has "Verified Answer" so I can close this thread.

    If you have any other question or concern, you can start a new thread.

    Thanks and Regards,

    Jean-Marc