We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello all, I have a bizarre problem that I hope someone will be kind to help me. I'm working with compiler ver7.02b, RTX51-full, and T89C51RD2. One of the variables (X) placed in xdata (address 0x19CC) is initialized to 3. For some bizarre reason when program is running this value is changed to zero. There isn't any place in my code where I set this variable to zero, because it's illegal in my case (acceptable values can be from 3 to 255). The compiler's optimization level is set to zero. I'm using Ceibo's emulator DS-51, but he doesn't support software breakpoints with write specific data to specific address location (I wanted to stop execution when zero is written to this specific address location). Does someone have any idea how to proceed? Thanks in advanced, Ruven
Hi Andy, I know that if I will write something about the built-in simulator the answers/help will be focus on that subject. As I wrote before, I have the Ceibo's emulator and also with him or without him I can't determine the cause of this bizarre problem. I made an experiment to set the variable in specific XDATA address location by using _at_ word. Now it seams to be OK. My added question is what is the reason for what happened? Why the program (maybe the operating system) sets a value in a global variable where no one asks him to do so? Thanks, Ruven
If moving the variable to another address changes the behaviour, this points at a buffer overrun or other wild pointer as the most probable reason. I.e. a bug somewhere in your code happens to construct a pointer to the address this variable is normally located, and overwrites it. Move it away, and that same bug will hit unused memory, or some other variable that now lives there. I strongly doubt there's any reasonable way you'll manage to track down this one without data write access breakpoints. About the only alternative would be to comment out larger and larger pieces of your program until the bug vanishes, then reactive parts of what you removed until it reappears. Repeat until you home in on some piece of it that misbehaves, and find the bug by just looking at the code in question (or posting it here...).