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.

Result of intrinsic _cmpyr is 0

   Hello,

i want to make use of the intrinsic _cmpyr function for complex multiply and used it like this:
   

    unsigned int r,a,b;
    a = 0x00040003;
    b = 0x00020007;
    r = _cmpyr(a, b);
    System_printf("Result %d\n",r);

but the result i get is "0" do you know how this can happen?
Is this the right code for multiplying 3+4i * 7+2i ??
Even when im multiplying 0x00030004 * 0x00070002 with _cmpyr i get 0 as the result.

best regards

Florian

  • ok,

    i figured out using _cmpy the result is right.
    I think i used too small numbers and the rounding  destroys my result.

    do you think so?

    best regards

    Florian

  • The compiler intrinsics map directly to the underlying C6000 CPU instruction.  You can look up how the instruction works in the relevant CPU instruction set book.  I'll guess you are using a C6600 device, which means this is the book.  If you carefully trace through how the instruction works, you can see that CMPYR only keeps the upper 16-bits of each multiply-add or multiply-subtract operation.  Carefully compare to CMPY to see it keeps the lower 16-bits of each operation.  I don't have the expertise to explain the difference.  I recommend you start a new thread in the C66x device forum about that.

    Thanks and regards,

    -George