This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Keil uVision debug BreakSet on infinite cycle

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

0