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.

compiler issue

Hi

I am using c5504 with DSP-BIOS 5.42.1.09 and compiler version 4.4.1

I have  ap piece of code that looks like:

xxx.h

#define INVALID_SLOT (0xFFFF)

xxx.c

void Task (void)

{

    uint16 slot;

    while (1)
    {

          MBX_pend(MBX_HND(TSK_A), &mbx_a, SYS_FOREVER);

         ...

slot = get_slot();
if (slot == INVALID_SLOT)
{
......
}
else
{
......
}

    }

}

In disassembly I see:

At the beginning of the function: 

MOV #-1,T2

and later:

//if (slot == INVALID_SLOT)
01f246: 2249 MOV T0,AR1
01f248: 129c64 CMPU AR1 != T2, TC1

BUT T2 IS NOT 0xFFFF !!!!!  (T2 value changed during program run)

my function result is compared to the wrong value, causing program malfunction.

Am I doing something wrong?

P.S.

I can overcome this issue if I write:

uint16 tmp = INVALID_SLOT;
if (slot == tmp).....

but it's ugly and ineffective