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.

the obfuscation about MPYF32

I use two consecutive MPYF32,like this:

MPYF32     R0H, R1H, R0H
MPYF32     R1H, R2H, R1H

why is R1H changed after executing the first instruction “MPYF32     R0H, R1H, R0H”?

I encounter this in C:

float a,b,c;  

c = a*a + b*b;

the assemble language of(c = a*a + b*b;)is :

MOV32      R0H, @20, UNCF
MOV32      R1H, @20, UNCF
MOV32      R2H, @6, UNCF
MPYF32     R0H, R1H, R0H
MPYF32     R1H, R2H, R1H
NOP       
ADDF32     R0H, R1H, R0H
NOP       
MOV32      @8, R0H 

 

Thanks a lot!

  • What exactly are you comparing? And how?

    e.g. Are you comparing the value of R1H immediately before the first MPYF32 is executed and after immediately it is executed?

    Are you using breakpoints or single-stepping?

    It looks like it might be something to do with the pipeline.

    And finally does

    c=a*a + b*b;

    give you the right answer in C?

    Tim

  • DEAR Tim:

            Thank you very much for your answer;

           the answer of (c=a*a+b*b) is right in C,but I can't understand why the the CCS3.3 compile the assemble language  of this math as follow:

    MOV32      R0H, #a, UNCF
    MOV32      R1H, #a, UNCF
    MOV32      R2H, #b, UNCF
    MPYF32     R0H, R1H, R0H
    MPYF32     R1H, R2H, R1H

    NOP       
    ADDF32     R0H, R1H, R0H
    NOP       
    MOV32      #c, R0H

    it looks like

          c = a*a +a*b;

    I compare the value of R1H immediately before the first MPYF32 is executed and after immediately it is executed by single-stepping;

    after the first MPYF32 ,the R1H is updated to the value of b; I'm confused  by the updated .

    Would you like to tell me which document illustrates this.

     

    wu qiang

    Best regards!