Binary sketch size: 11368 bytes ...It was 450 bytes.
Count again. I'm betting that you inserted 5459 no-ops, not 5461. (450 + 2*5459 = 11368)
Since we are being silly, I pasted exactly 5461 no-ops into the setup()
function of the Blink example sketch.
Original size was 990 bytes. With 5461 no-ops, the size is 11912 bytes. (990 + 2*5461 = 11912)
With an empty sketch like yours, the size went from 428 bytes to 11350 (428 + 2*5461 = 11350)
Note that small differences in absolute code size (428 bytes contrasted with 450) are undoubtedly due to different compiler versions, but the important thing (if anything in this thread---up to this point---can rightly be called important) is that each no-op increases the sketch size by exactly two bytes, as I previously claimed. No extra junk that I can see.
On a more serious point, I am very interested as to how the no-ops function works. I have never heared of the asm() function before, and a google search reveals the American Society for Microbiology. What is it meant to do?
function is not a standard C (or C++) library function. It is supplied by the compiler/library vendor to allow programmers to insert assembly language instructions in the middle of their C programs. You can read about it here: avr-libc: Inline Assembler Cookbook
The no-op instruction itself does exactly what its name implies: Does not affect the state of the CPU, i.e. it doesn't change contents of memory or registers or change flags or anything else. It has to be fetched from memory, like all other instructions, and it takes exactly one clock cycle to fetch the instruction and do nothing else.
What is the asm()
function good for? Well, sometimes people think they are smarter than the compiler and they use asm()
stuff to force certain instructions to be executed rather than trust the compiler to create assembly code that is as tight as it can be. (Sometimes they are even right!)
What is the no-op instruction good for? Well sometimes people need to fine-tune the timing of their programs for various real-time purposes. For example the SD library uses no-ops in a couple of places to make sure that external setup and hold times are met for certain of the SPI data transfers. I have used no-ops in assembly language programs where I needed to equalize delay times between different branches of a routine that was generating symmetric waveforms
Stuff like that.
Since the asm()
function is not a standard C or C++ library function, its actual syntax requirements may change. I experimentally determined that the simple form that I showed works for me in this test. If I were going to use this seriously, I might use the form shown in the avr-libc reference that I gave (which is the form that is used in Sd2Card.cpp in the utility directory of the SD library).