??? 03/03/10 22:18 Read: times |
#173801 - so is your problem solved or not? Responding to: ???'s previous message |
Munish Kumar said:
Anyways the problem is solved by changing buffer[2] to buffer[3] & assigning last byte 0. Yes, that's it. Now I don't quite understand what are you complaining of - is it the difference between simulation and the real thing? The exact behaviour of your previous code, i.e. without having a terminating zero in buffer[2], depends on what is allocated after the buffer[2] array. It may quite well be a local variable, which hasn't been accessed yet; and, as such, that byte in RAM should have an undetermined value, given by how the RAM cells settle upon powerup, or from previous runs of the program if it has reached the routine overwriting this memory byte; it's very unlikely it will be zero. On the other hand, upon starting a simulator, they tend to fill the area which represents the RAM locations by zeros, which in this case would result in an unintentional terminating zero for your 2-byte "string" in buffer[]. I don't say this IS the explanation of what you've seen, but this may be one of the scenarios leading to perceived discrepancies between simulation and real running of a - basically incorrect - code. Jan |