View previous topic :: View next topic |
Author |
Message |
ecoology
Joined: 07 Nov 2006 Posts: 340 Location: USA - California
|
Posted: Fri Jul 25, 2008 1:11 am Post subject: When is a program not the same program? |
|
|
sorry for the cryptic title. I didn't know what to call this.
I have a program that works [uses the mega168, but that is irrelevant].
I copied all of the files, bas, CFG, HEX, etc to a new folder. I want to create a slightly different version of the program.
I verified the original program to my target board. Everything is good.
I then, just to be sure, verified the HEX file in the new folder. It was good. Then, I recompiled the bas file [ the exact same file as in the first folder, nothing changed]. This "new" HEX file failed!
I then did a comparison of the two HEX files. they are significantly different.
I loaded the "new" HEX file into the chip. It appears to work exactly the same as the "old" file.
The same .bas file, the same .cfg [I checked them also], and yet I get two radically different HEX files - both of which work.
The first 4 lines of HEX code are the same, and from there, every line is different - not even close.
What else needs to be the same, beyond the bas, and CFG files? I checked under "options", "compiler" and "chip" and everything appears to be the same.
I'd love to hear an explanation for this. Again, both HEX files work, so the compiler is not corrupting the program, it is just producing two versions of the same thing - but why I do not understand. |
|
Back to top |
|
|
Ross_ValuSoft
Joined: 20 Nov 2005 Posts: 275 Location: Melbourne, Australia
|
Posted: Fri Jul 25, 2008 3:10 am Post subject: |
|
|
Hi,
A wild guess ... you have two versions of Bascom installed and when you moved to a different folder you lost the path settings to the original version and picked up the different Bascom version. As I said ... a wild guess (based upon having done it myself )
Cheers,
Ross McKenzie
ValuSoft
Melbourne Australia |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Fri Jul 25, 2008 3:13 am Post subject: |
|
|
Once the compiler generates even one byte different in the code, for any one of a huge number of reasons, the rest of the file can be wildly different. As long as the hex file works, dont worry about it. I agree that under your conditions the two files should be the same, but I can imagine even a tiny difference in how the compiler does its optimisation will do this.
If you really want to see what the diffs are, use a disassembler, and see where the change started. Its probably something really simple, like putting a Sub in a different location. At least, the compiler inserts the date-time of the compilation in the code. ( So the Version string is changed ) Since that is bound to be different, it will probably be enough to change everything else. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
ecoology
Joined: 07 Nov 2006 Posts: 340 Location: USA - California
|
Posted: Fri Jul 25, 2008 4:03 am Post subject: |
|
|
Ross, I should have stated. This is two folders on the same computer, running the same version - same program actually, of BASCOM. The exact same program compiled both versions.
I agree with Adrian, one byte difference and it all can change. BUT why wouldn't the compiler compile the same program twice exactly the same?
This is just a curiousity, I shouldn't obsess. We all think that software is predictable. Maybe not to the extent we assume. |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Fri Jul 25, 2008 5:36 am Post subject: |
|
|
I just tried this on one of my programs. Simply compiling, saving the hex file as a different name, and then recompiling exactly the same source a few minutes later produces a different hex file, admittedly only in a few bytes, not quite what you see, but still...
Your only answer, if you really need to know, is to look with a disassembler. Personally I would trust that Bascom produces a working program, and leave it at that. I dont see any point in comparing hex files, as I said, totally irrelevant changes to your source, like swapping the order of Subs, will produce completely different hex files, but they will both work identically. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Klauss
Joined: 06 Dec 2005 Posts: 9 Location: Jo-burg
|
Posted: Fri Jul 25, 2008 7:13 am Post subject: |
|
|
something to do with the 'version' function?
see:
Var = VERSION(frm)
_________________ K. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|