Compiler voodoo

I guess this is a philosophical general programming question, but since it is about Arduino IDE, I post it here.

I've managed to write some test code after getting to know some basics of AVR assembly and registers, thanx to help I got here, for which I am grateful.

Code is about communicating to TM1637 7-seg display using assembly on ATtiny13, and I saved quite a lot of memory thanx to westfw's help (saving about 150 bytes so far).

BUT, after compiling and uploading a nice working version of this test code, I saved source files to archive named "this works", and after some minor changes in code, it does NOT work, okay - that's normal.

What drives me crazy, is that now, whenever I try to compile&upload this good working version I extracted from archive, it DOES NOT work.

After upload, TM1637 displays some trash and after unplugging/plugging back the USB which is powering my Arduino&ATtiny, TM1637 displays nothing.

Other sketches using TM1637 work fine so the hardware is not dead, but this test code I made, and which once worked (tested it successfully few times before archiving it to RAR) no longer works!

I guess I'll get "show us the damn code" comments but I don't have it with me now and I cannot possibly see how the code can have anything to do with this problem.

I guess I'll get "show us the damn code" comments but I don't have it with me now and I cannot possibly see how the code can have anything to do with this problem.

Must be a vision issue, then, because I can not see how code that fails to work is anything but a code issue.

Are you sure that you saved the working code ?
Are you sure that you saved it with the right name ?
Are you sure that you saved it where you thought you did ?
Is there more than one file with the same name in two (or more) different places on your PC ?
Do you use any form of version control, even if it only numbering different versions so that you can go back to them ?

OK I'll spare you my sarcasm. Programming sucks.

I suggest sabotage, possibly a virus.

a7

I suggest sabotage, possibly a virus.

I heard hoof-beats. Be on the lookout for a zebra.

PaulS:
Must be a vision issue, then, because I can not see how code that fails to work is anything but a code issue.

No, no - a code worked, and after compiling it few times more, stopped working - but I'm absolutely positive it worked! I deleted contents of c:\Users\usr\AppData\Local\Temp folder thinking that compiler is maybe not refreshing to new code, but still it doesn't work... Anyhow, I'm at work and don't have the code now...

after compiling it few times more, stopped working

Why would you need to compile working code "a few more times"? You must have pissed the code off doing that, and now it is getting its revenge.

losmi:
What drives me crazy, is that now, whenever I try to compile&upload this good working version I extracted from archive, it DOES NOT work.

My guess is that you accidentally replaced the working version with the non-working version.

...R

UKHeliBob:
Are you sure that you saved the working code ?
Are you sure that you saved it with the right name ?
Are you sure that you saved it where you thought you did ?
Is there more than one file with the same name in two (or more) different places on your PC ?
Do you use any form of version control, even if it only numbering different versions so that you can go back to them ?

Sorry, I can post only once in 5 minutes as a noob.

As long as my reason is reliable, I am positive that I use the same code which worked well.

I saved it in RAR archive, in the sketch folder.

There are two source files - one .ino file and one .S file with assembly code.

Unfortunately, I don't use any means of version control, nor do I archive/snapshot source code on regular basis.

PaulS:
Why would you need to compile working code “a few more times”? You must have pissed the code off doing that, and now it is getting its revenge.

I was making some minor changes, to save few more bytes of memory. But it all worked. And after it got angry, stopped working.

So, is the general conclusion, funny comments aside, that same code cannot work and not work, like Shrodinger's cat? If that's the case, I'll look byte by byte for a bug.... Looking forward to it !%@^*

I have no doubt that you will solve this problem.

Please be extremely careful as you do, so that you can come back here and tell us what it turned out to be!

I believe that we can benefit from your situation. It will give weight to some step in the process everyone uses, explicitly or implicitly, in error hunting.

It may well not be your problem, but you can tell from the tone of the replies here that > 99.44 % of the time it is you.

alto777:
It may well not be your problem, but you can tell from the tone of the replies here that > 99.44 % of the time it is you.

Yap, I’m aware of it but that does not help too much :slight_smile: Anyways, I was pretty sleepy last night when this happened so, it was probably me, as it so often turns out…

Haha! In a response I didn't post, just not helpful prolly a little mean def sarcastic… I actually had a line about sleepy and/or caffeine fueled development sessions where the changes are a-flyin' and there's virtual litter all over the environment and you don't know up from down and how could this possibly be doing (or not doing) what is it I am so tired of this it worked I swear!

Been there. Feel your pain, man.

a7

:smiley:
while (stillHavePatience) {
fallAsleepWhileTyping();
eraseRandomPortionOfCode();
wakeUp();
undoHopefullyJustTheRightNumberOfTimes();
}
goToBed();

Say, you don’t perchance have a cat?

alto777:
Say, you don't perchance have a cat?

Nope, no pets currently, but I used to have various critters before the kids came :slight_smile:

losmi:
Nope, no pets currently, but I used to have various critters before the kids came :slight_smile:

Kids were hungry ?

...R

When using assembler, you are more likely to create bugs related to uninitialized data. Some memory location will contain zero and everything will work fine, and the you’ll do something that results in the memory NOT containing zero, and it will stop,working....

westfw:
When using assembler, you are more likely to create bugs related to uninitialized data. Some memory location will contain zero and everything will work fine, and the you’ll do something that results in the memory NOT containing zero, and it will stop,working....

Thanx for the tip, but currently this program does not reference any memory outside of registers, only uses immediate values.