Hi,
a snippet of my c-code looks like this:
----------------------------------------------------------------------------------------------------------------
if (tempa == 0)
{
Ergebnis = 0;
}
}
Wait_ms (100);
----------------------------------------------------------------------------------------------------------------
With a breakpoint on the if statement the contents of tempa is 9 (= correct in this case).
Next singlestep stops @ Ergebnis = 0 which pretends that tempa is 0 (= obviously not correct).
With a look at the assembly the program flow is ok because with the BNE in effect program execution
resumes with the preparation of the wait-loop. But this is not part of the Ergebnis statement.
The program is running fine but debugging is misleading .
----------------------------------------------------------------------------------------------------------------
In assembly the code reads :
if (tempa == 0) ;Breakpoint, tempa currently = 9
080039AE 7800 LDRB R0, [R0, #0]
080039B0 2800 CMP R0, #0
080039B2 D102 BNE 0x080039BA ;Branch active because tempa != 0
080039B4 A802 ADD R0, SP, #8
080039B6 2100 MOVS R1, #0
{
Ergebnis = 0;
080039B8 7001 STRB R1, [R0, #0]
080039BA 2064 MOVS R0, #100 ;Branch destination = start of Wait_ms(100)
}
}
Wait_ms (100);
080039BC F7FE FC70 BL Wait_ms
080039C0 A802 ADD R0, SP, #8
a snippet of my c-code looks like this:
----------------------------------------------------------------------------------------------------------------
if (tempa == 0)
{
Ergebnis = 0;
}
}
Wait_ms (100);
----------------------------------------------------------------------------------------------------------------
With a breakpoint on the if statement the contents of tempa is 9 (= correct in this case).
Next singlestep stops @ Ergebnis = 0 which pretends that tempa is 0 (= obviously not correct).
With a look at the assembly the program flow is ok because with the BNE in effect program execution
resumes with the preparation of the wait-loop. But this is not part of the Ergebnis statement.
The program is running fine but debugging is misleading .
----------------------------------------------------------------------------------------------------------------
In assembly the code reads :
if (tempa == 0) ;Breakpoint, tempa currently = 9
080039AE 7800 LDRB R0, [R0, #0]
080039B0 2800 CMP R0, #0
080039B2 D102 BNE 0x080039BA ;Branch active because tempa != 0
080039B4 A802 ADD R0, SP, #8
080039B6 2100 MOVS R1, #0
{
Ergebnis = 0;
080039B8 7001 STRB R1, [R0, #0]
080039BA 2064 MOVS R0, #100 ;Branch destination = start of Wait_ms(100)
}
}
Wait_ms (100);
080039BC F7FE FC70 BL Wait_ms
080039C0 A802 ADD R0, SP, #8