Okay, so after a week looking into this I am sure this is a bug in CCS V5.3 relating to C5535 (V3 Simulator) - or perhaps the <stdarg.h>
Here is the effect I am seeing - can anyone confirm if they have the same problem? - Or indeed can see what I am doing wrong.
Background:- Porting an audio codec for use on the C5535 DSP. Have already done it for C6000 which had no problems, but now on the C5535 the functions with variable length argument lists are failing depending on data content on the variables.
I have written this test example to demonstrate the problem.
void testFunct_a( int testword , int count, ... );
int main(void) {
testFunct_a( 1111, 4444, (long)32800L ); // FAILS ( first argument wrong)
testFunct_a( 2222, 8888, (long)32760L ); // PASSES
printf("Hello World!\n");
while(1);
return 0;
}
void testFunct_a( int testword , int count, ... )
{
va_list ap;
va_start(ap, count);
printf("count %0d \n",testword);
printf("count %0d \n",count);
long value = va_arg(ap, long);
printf("count %8.8ld \n",(long)value);
va_end(ap);
return;
}
The console display output:-
count 0
count 4444
count 00032800
count 2222
count 8888
count 00032760
The closest I have got to understanding this is that as the constant value 32800 / 32760 goes over the boundary for a singed int (16bits) then the parameters list in stack changes somehow.
I really need a solution to this - either what I am doing wrong or if this is a compiler bug. The codec being ported uses a lot of variable length argument list functions - if these won't work on the C55 platform I need to start porting all those functions.
Any help much appreciated.
Some of things I think might be related..
1) I read in the C55 datasheet bytes and ints are both 16bit. But more alarmingly doing a sizeof(byte) or a sizeof(int) actually returns 1? (This is detailed in page 84 of SPRU281G TMS320C55x Language manual). Does Stdarg.h use sizeof? etc.
Rob