There is some questions about testing using function editor tool in keil uvision (debugger mode). There is code which is to be tested:
void init_ports(){ if( IDCHIP == 0x2302 && IDMEM == 0x3040){ ... label_1:; }else if( IDCHIP == 0x2381 && IDMEM == 0x3020){ ... label_2:; }else{ label_3:; while(1); }//if label_4:; }
1. Why do I have to use ";" symbol folowing label_1, label_2, label_4 to avoid "error C25: syntax error near '}'"?
2. Compiler places 3 "RETS" instructions here: on label_1, label_2 and label_4 (to optimise using one JMP instruction). But why does compiler place here 3rd "RETS" instruction on label_4, which is dead code (never reached)?
3. Main question. When this code is being tested by following commands, there is no breakpoint set on label_3. But when this breakpoint is set manually (mouse click) on "while(1)" before running this test, debugger shows warning that breakpoint on label_3 is allready set.
bs \module\label_1, 1, "_break_=1" bs \module\label_2, 1, "_break_=1" bs \module\label_3, 1, "_break_=1" bs \module\label_4, 1, "_break_=1" $ = \module\init_ports g , \module\label_4
The language standard requires that there is one or more statements after a label. It's similar when you add labels to a switch block - your "default:" label expects one or more statements to follow.
And ';' alone adds a null-statement.
Another thing to consider is that breakpoints and actual results depends extremely on optimziation levels and code generation - there may not be any good machine instruction address to place the breakpoint on, after the compiler has performed the flow control and emitted actual processor instructions.