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.

Invalid compiler output for 5505

I'm using the following options with cl55.exe (version 4.3.9)

 -vcore:2 -vcore:3 -g -O2

The target is the C5505 (TMS320C5505AZCHA12). I'm compiling with -vcore:2 and -vcore:3 because we have to link with an existing library.

If I have the following code :

===================================================

Uint16 tmp, *cmdPtr = (Uint16 *)0x400000;      // pointer to external memory

tmp = *cmdPtr++ >> 8;

===================================================

then tmp contains 0 in a lot of cases even when the upper 16 bits of the data pointed to by the pointer is non-zero. The same code on a 5507 produces an output which works.

Replacing

tmp = *cmdPtr++ >> 8;

with

tmp = *cmdPtr++;

tmp >>= 8;

produces the correct result in tmp.

The problem syntax occurs a LOT in my project. Has anyone seen this and know how I can fix it without replacing everything occurence in the project? I can provide the disassembly but I don't see how this will help. The compiler output is clearly wrong.

Thanks in advance,

Cameron.

 

 

  • What memory model are you using?  If the options you show are the only options you are using, you get small memory model, in which case 0x400000 doesn't fit in a pointer.

    I wrote a test case with code similar to the fragment you provide; I don't see anything wrong with the compiler output.  It would help to see the disassembly for both versions of the code to at least verify that the compiler is producing the expected assembly code.  Since it works for 5507, I suspect there's nothing wrong with the compiler.

    I suspect the high_byte operand of misbehaving when reading the external memory in your system.  Try using the --no_byte_operands option.

  • Fantastic! The --no_byte_operands option solved the problem.

    Incidentally, I was using the large memory model correctly.

    Thankyou very much!