I recently upgraded to v5, update 9.1.
The compiler emits a jump to a function "__spswitch32" whenever it comes across a C switch statement with more than 3 labels. I was able to find the source of this function: "<VDSP>\Blackfin\lib\src\libc\runtime\spswitch32.asm". As expected it consists of a loop which searches a table for the expression value, then jumps to an address.
Anyway I noticed something odd about that function.
The implementation uses a hardware loop, and jumps out of the hardware loop to a label ".found" when the expression value is found. The assembly source contains the following at the label mentioned :-
// LC0 = 0; ???
P1 = P4 + (P3<<2);
P1 = [P1]; // lab = labels[mid];
(P5:3) = [SP++];
This puzzled me. Why is that "LC0=0" line commented out? The syntax is actually illegal (you can't "load immediate" into LC0), but still the intent was clear: the code breaks out of hardware loop with LC0!=0, i.e. with the CPU thinking its still in a loop, hence the programmer basically wanted to "turn the loop machine off". Is it a bug that he didn't?