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

Weird behavior on C51 Simulator/Debugger

I have a doubt regarding the simulator/debugger tool. In the window displaying the code, one can see that the left-most column would be highlighted green once the line of code is executed.

My doubt is, if the code of a particular function is for example the following :

void example(char abc){ //Line 1
/*some code*/
}

is Line 1 suppose to be executed ? (Will the left column of that particular line be highlighted green?) Interestingly, my observation is that some of the functions in my program has it's first line highlighted while some don't when I execute my program.

I am also experiencing weird behavoir when the first line of the function is not executed (ie highlighted green). Using the above example, I call the function

....
example(1);
....

and pass in a value of 1 as the parameter abc. However, when my program runs to the function code itself, the value of char abc is not 1 eventhough the value passed in is clearly a 1.

I might be missing out something. Could anyone possibly provide some reasons for this unexplained behavior.

Thank you.

Parents
  • It takes perhaps many lines of assembly to make one line of C. This is particular true for "lines" like function calls.

    Setting a breakpoint on the name of the function most likely stops at the first instruction, before the parameters are established in whatever location the debugger expects them a little later.

    It's easier to debug at the source level when you put less stuff on a single line. In this case, even '{' represents "stuff".

Reply
  • It takes perhaps many lines of assembly to make one line of C. This is particular true for "lines" like function calls.

    Setting a breakpoint on the name of the function most likely stops at the first instruction, before the parameters are established in whatever location the debugger expects them a little later.

    It's easier to debug at the source level when you put less stuff on a single line. In this case, even '{' represents "stuff".

Children
No data