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
  • Note that some of the higher optimisations in the latest Keil version are performed by the Linker; ie, the Linker modifies the code after it is generated by the compiler.

    Interesting dilemma. I'm with Erik, if the compiler listing does not match the executing code how will someone (probably me) find those pesky little undesirable features that seem to arise ... after release ... in large projects.

    Unless I am really strapped for space, I only let the compiler optimize and skip the LX linker.

Reply
  • Note that some of the higher optimisations in the latest Keil version are performed by the Linker; ie, the Linker modifies the code after it is generated by the compiler.

    Interesting dilemma. I'm with Erik, if the compiler listing does not match the executing code how will someone (probably me) find those pesky little undesirable features that seem to arise ... after release ... in large projects.

    Unless I am really strapped for space, I only let the compiler optimize and skip the LX linker.

Children
  • if the compiler listing does not match the executing code how will someone (probably me) find those pesky little undesirable features that seem to arise

    Congratulations, you've just re-discovered the reason why LX51, which does those kinds of optimization, comes with its own listing option ("linker code listing" on the listings page of uV2).