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.

Compiler/UCD3138: two 32-bits data multiplication result is not correct

Part Number: UCD3138

Tool/software: TI C/C++ Compiler

Hi,

I am using CCS6.1 with compiler 5.22. I found the result of multiplication of two 32-bits data is not correct.  I defined the result as 64 bits data. the correct result should be 0x0000 0056  0038 7512. I saw one register R0 has the number 0x0000 0056, another register R1 has the number 0x00387512,  which is correct. however, the result I get is 0x0038 7512 0000 0056, which seems the two registers's data are put in the wrong order.

Is it a bug or I didn't configure the CCS correctly?

Thanks,

Julie

18 Replies

  • Can you show your code snippet?
  • In reply to Keith Barkley:

    the code is :

    Uint16 uint16_multiply_shift_clamp(Uint32 x, Uint32 y, int16 shift, Uint16 max_value)
    {
    Uint64 scale_product_64;

    scale_product_64 = (Uint64)x*y;

    .............

    }

    I tried to declare the variable scale_product_64 as a global variable, then the result is correct. 

    please refer to attached document.  I put all the screen captures into this document. 

    Thanks

    Julie64-bits multiplication.docx

  • In reply to Julie Zhu:

    The question is are you casting x to uint64_t or x*y to uint64_t? IF the latter, the multiplication will still be 32 bit.
    Try ((uint64_t)x) * y
  • In reply to Keith Barkley:

    I am pretty sure that is not the reason.

    first, I used the same statement for the case that scale_product_64 is declared as global variables. the result is correct.

    second, I tried different ways, like scale_product_64 = ((Uint64)x)*((Uint64)y); the result is same.

    but know I figure out it might just be a issue of displaying inside the debugger. I think the display has a bug that arrange the words in the wrong order.
  • In reply to Julie Zhu:

    This is expected behavior.  When a 64-bit integer value resides in a register pair, the even register holds the high order bits, and the odd register holds the low order bits.  When inspecting 64-bit values, avoid looking at the registers.  It is easy to get confused.  Look in the watch window, or something similar.

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click This Resolved My Issue on the best reply to your question
    The CCS Youtube Channel
     has short how-to videos
    The 
    Compiler Wiki answers most common questions
    Track an issue with SDOWP. Enter your bug id in the Search box.

  • In reply to George Mock:

    George Mock

    This is expected behavior.  When a 64-bit integer value resides in a register pair, the even register holds the high order bits, and the odd register holds the low order bits.  When inspecting 64-bit values, avoid looking at the registers.  It is easy to get confused.  Look in the watch window, or something similar.

    I think Julie gave an example where the watch window would show a wrong 64 bit value (namely, when the variable was stored in a register rather than in memory). That looks like a bug in CCS to me (not in the compiler, though).

    Markus

  • In reply to Markus Moll:

    George,

    If you look at the screen capture I provided, the data shown in the watch window is in wrong order when it arranges the 64-bits data from 2 registers.  Should be a problem in the watch window display.

    Julie

  • In reply to Julie Zhu:

    Julie Zhu
    If you look at the screen capture I provided, the data shown in the watch window is in wrong order when it arranges the 64-bits data from 2 registers.  Should be a problem in the watch window display.

    I tried to repeat the problem using the ARM9 core in a AM1808 using CCS 6.1.2.00014 and TI ARM compiler v5.2.0 (the closest versions to those you are using which I had installed). I couldn't repeat the problem, in that the sum 64-bit sum variable held in a register pair was displayed correctly in the variable view:

    In the above working example the 64-bit variable sum is given a register-pair location of "R8:32,R9:32" in the Variables view, whereas in your failure case the location is given as "R0" which is a single 32-bit register.

    Can you post an example project which shows the problem, along with the exact CCS version number? Not sure if the problem is either:

    a) A bug in the CCS version you are using.

    b) The debug information generated by the compiler has specified the wrong register location for the 64-bit scale_product_64 variable.

  • In reply to Chester Gillon:

    Hi, Chester,

    the CCS version I am using is Version: 6.1.0.00104.  the project is for UCD3138, I have attached the screen capture for the details.

    Julie

  • In reply to Julie Zhu:

    Julie Zhu
    the CCS version I am using is Version: 6.1.0.00104.  the project is for UCD3138, I have attached the screen capture for the details.

    Thanks for the information. I don't have that CCS version installed and don't have a UCD3138 so can't re-create the problem to investigate.

    Not sure if it is significant, but the UCD3138 is big-endian, whereas the ARM devices I failed to re-create the problem with are little-endian. Hopefully someone from TI can repeat the problem with a UCD3138.

    Are you able to try a later CCS version to see if the problem has been fixed in a later version?

    E.g. found Expressions and variables windows not displaying correct values which was reported against CCS  6.1.0.00104, for which bug SDSCM00051806 was raised which was fixed in CCS 6.1.1

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.