AnsweredAssumed Answered

Possible bug in the switch statement for Coldfire V1

Question asked by Gustavo Denardin on Sep 14, 2011
Latest reply on Sep 14, 2011 by kef

Hi everyone,


We are facing a lot of problems with switch statement for coldfire V1 in the CodeWarrior 6.3 IDE.If we use a unsigned char (INT8U in our code) variable for "if" and "while" statements the compiler works well. However, for "switchs" the compiler makes the test with long (32 bits), not for unsigned char (8 bits). If there are some trash in the used register, the test fails.


I'm attaching  a sequence of images that show this behavior.


Is there any workaround for this compiler bug? This is very annoying, since a lot of code from other people (like FATFS) makes use of switch statements for unsigned char variables.


I'm also attaching the source code. The problem occurs in the SD_API.c file, in the function:

INT8U file_name_verify(INT8U *pname1,INT8U *pname2, INT8U *pfile, INT8U num)


The problem could be seen in the disassembly of this file.


Thanks in advance,