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.

Double literal constants don't seem to work with the ARM compiler.

Other Parts Discussed in Thread: OMAP-L138, OMAPL138

I seem to be having issues with double literal constants. 

I place a breakpoint on one of the executable lines and then use the emulator to display the variables.

Here is the code:

void test_exp_const (void)

{

   double test_number[] = { 1.2E1, 2.3E45, 3.4E-6, -4.5E1, 5.6E-7};

   float test_other[] = { 1.2, 0.345678, 34E5, -0.3425, 0.1234E-5 };

  test_number[0] = test_number[0] * 2;

  test_other[0] = test_other[0] * 2.0;

}

Here is what the emulator claims the numbers are:

test_number double[5] 0xC3001420 0xC3001420 
 [0] double 5.317941111879522e-315 0xC3001420 
 [1] double 3.209647124124661e-149 0xC3001428 
 [2] double -3.612240986106951e+021 0xC3001430 
 [3] double 1.593779568798647e-314 0xC3001438 
 [4] double 3.646871873938355e-280 0xC3001440 
test_other float[5] 0xC3001448 0xC3001448 
 [0] float 1.2 0xC3001448 
 [1] float 0.345678 0xC300144C 
 [2] float 3400000.0 0xC3001450 
 [3] float -0.3425 0xC3001454 
 [4] float 1.234e-06 0xC3001458 

The floating point numbers are fine, but all the doubles are really bad.  It is interesting to note that I can use the emulator to change the numbers and they seem correct.

 

 

  • I should add that I compiled this code on the DSPside of an OMAP-L138 and it works fine.  So this only seems to be an ARM side issue.

      ARM Compiler Tools 4.9.4 com.ti.cgt.tms470.4.9.win32.feature.group Texas Instruments

      C6000 Compiler Tools 7.3.5 com.ti.cgt.c6000.7.3.win32.feature.group Texas Instruments

     

     

  • Somewhere along the way, the words of the double are being reversed. 1.2E1 is (big endian) 0x4028000000000000, and 5.317941111879522e-315 is 0x0000000040280000

  • Interesting...

    So I started looking at the settings I have and I saw that I was picking a particulate Floating Point Library.  I changed it so that nothing was selected and not it seems to work.

    So that brings up the question of, where is the documentation for the different Floating Point Librarys are so that we know what to choose?

    Here is the screen I am talking about with the library that failed.  When I select nothing (or get the window blank) we seem to work.

    So what does that mean?

    Thanks!

  • I'm sorry, I don't know enough about ARM to answer that.

  • We should figure out where the bug is, so that the appropriate workaround can be applied, and so that TI can fix the problem. Is the only symptom that the emulator cannot display the values correctly? Does the program run correctly otherwise? If you could tell me the value of test_number[0] and test_other[0] at the end of the function test_exp_const, I should be able to make an educated guess.

  • With the fpalib...

    Before multiply:

    test_number[0] double 0x0000000040280000 (Hex) 0xC3001420

    test_other[0] float 0x3F99999A (Hex) 0xC3001448 

    After multiply:

    test_number[0] double 0x0000000000000000 (Hex) 0xC3001420 

    test_other[0] float 0x00000000 (Hex) 0xC3001448 

    Without the fpalib (entry is empty)...

    Before the multiply:

    test_number[0] double 0x4028000000000000 (Hex) 0xC3001420 

    test_other[0] float 0x3F99999A (Hex) 0xC3001448 

    after the multiply:

    test_number[0] double 0x4038000000000000 (Hex) 0xC3001420 

    test_other[0] float 0x4019999A (Hex) 0xC3001448 

     

     

     

  • That seems inconsistent between double and float... Could you please post the exact command line options you are using to compile with?  It might also help to see the linker map file.

  • Mike Geppert said:
    where is the documentation for the different Floating Point Librarys are so that we know what to choose?

    Please see the section titled VFP Support in the ARM compiler manual.

    Thanks and regards,

    -George

  • According to the documentation the fpalib uses Big Endianness  which is what we were seeing.  Also indicates that it is for ARM11 and above we are on an OMAPL138 which is a ARM9.

    This takes care of the issue.