This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NCS/Segger Debug Error

Here is a screenshot of my current debug session. I cannot figure out why this if statement is failing. I have circled the relevant information. Even the disassembly indicates it should not take the branch but yet it does??? Values are an exact match... Is this a bug in Segger, the compiler, or what??

Parents
  • I may be missing your intention, but the code looks correct and is returning 0 in R0 as the value tested in the if statement is indeed equal; if it were not equal it would return 21 in R0. The jump to AC8A is taken when the if test indicates equality, slightly different perhaps from what might be expected. A second jump back to AC80 is then taken to share the inequality exit code with result in R0.

    beq AC8A is taken if the value is the same, in other words a not not-equal test.

Reply
  • I may be missing your intention, but the code looks correct and is returning 0 in R0 as the value tested in the if statement is indeed equal; if it were not equal it would return 21 in R0. The jump to AC8A is taken when the if test indicates equality, slightly different perhaps from what might be expected. A second jump back to AC80 is then taken to share the inequality exit code with result in R0.

    beq AC8A is taken if the value is the same, in other words a not not-equal test.

Children
Related