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.

[CLA] MADDF32 instruction on F28035

Hi,

I'm using the MADDF32 instruction to make addition to "A" variable. But "A" variable not increse. "A" variable have saturation like a 16.0, 32.0, 64.0, 128.0...

Here is my test code below.. Please help me !

MMOV32 MR1,@_A
MMOV32 MR0,@_B
MMPYF32 MR0,MR0,#2.8444444444444444444444444444444e-6   
MADDF32 MR0,MR0,MR1
MMOV32 @_A,MR0

Thanks,

  • Hi,

    What are the initial values for A and B and what are the expected values for this set of operations?

  • Hi,

    Thanks for your reply.

    I found my problem here. Problem is adder for floating pointer.

    I expect variable value  "A" : 0.001 ~ 30.000, "B" : 2.8444444444444444444444444444444e-9 ~ 0.3072.

    Could you advice me how can make simple accumulate addition function with CLA? (Variable "A" will increse up to 30.000.)

    Many Thanks,

  • Im still not clear as to what you are trying to implement. From your earlier code it looks like you were trying to do this:

    A = B*2.84444...4e-6 + A .

    Do you want to keep doing this operation until A = 30.0?

    First I wouldnt recommend using the MMPYF32 MRa,MRb,#16FHi instruction for high precision increments. The closest representable number in single precision float for 2.8444444444444444444444444444444e-6  is 0x363EE32F. By using the above instruction you are multiplying B by only the high word of the immediate operand i.e. 0x363E0000 ( 2.8312206E-6) so you could do this instead:

        MMMOV32 MR1,@_A
        MMOV32  MR0,@_B
        MMOVF32 MR2,#2.8444444444444444444444444444444e-6
        MMOVF32    MR3,#30.000
        MMPYF32 MR0,MR0,MR2                               ; MR0 = B*2.8444445E-6
        MADDF32    MR1,MR0,MR1                            ; A(MR1) = (B*2.8444445E-6) + A(old)
    _Loop:
        MCMPF    MR1,MR3                                        ; Compare MR1(accumulated result)with MR3(30.00)
        MNOP
        MNOP
        MNOP
        MBCNDD    _Loop,LT                                    ;Keep accumulating till MR1 > 30.00
        MNOP
        MNOP
        MNOP
        MMOV32 @_A,MR1                                        ;Store accumulated result back in A

     

    I have used an inequality as the condition for my branch. Since you have a really high precision increment the result of the operations would probably not give you an exact 30.00. I havent tested this code out but im pretty sure this would work. Hope this helps

  • Hi,

     Thanks for your support.

    1. Variable "A" range is 0.001 ~ 30.000. (Not fixed.)

    2. My problem is here to use CLA code below. This code will call every 10.24mS.

    Ex) A = 128.0 (0x43000000), B = 1.402874 (0x3FB3915C)

    My expect value is  "A"  = 128.00000399039715555555555555556.  >> 128.0 + (1.402874 * 2.8444444444444444444444444444444e-6 )

    But "A" is does not increase from 128.0. I want to increase "A" value maximum 300.000.

    MMOV32 MR1,@_A
    MMOV32 MR0,@_B
    MMPYF32 MR0,MR0,#2.8444444444444444444444444444444e-6  
    MADDF32 MR0,MR0,MR1
    MMOV32 @_A,MR0

    Thanks,

  • The first increment (by your equation) is around 0.000003990397 and so you expect 128.000003990397. This number is not representable in single precision so no matter how many times you add that small increment the result of MADDF32 is always going to give you 128.0.

    When you have numbers that are an exact power of 2, e.g :2^7 = 128, the closest representable number is 128* (1+2^-23) = 128.0000152587890625 and you cannot use double precision with the CLA, (atleast Im not sure how you would emulate that).

    To get it to work you have to make sure your increment is >= 0.0000152587890625