I wrote a program that should create an square wave using an assembly macro (just to see how it worked), using the asm keyword in C. I am using 64 "NOPs" at 16MHz.
It works just fine, but if I call several times the same macro I get the following error:
/tmp/ccQo9mux.o: In function `main':
/home/luis/project.c:103: relocation truncated to fit: R_AVR_7_PCREL against `no symbol'
make: *** [video.hex] Error 1
I'm guessing that the code block with the six consecutive macros (64 * 6 = 384) is too long for a program counter-relative jump to get around.
The compiler would normally be able to insert "dead" instructions to allow it to leap-frog through long code sections, or generate direct jump instructions, but because these are your macros, it can't.
Not sure how to fix that at the moment.
Maybe an equivalent-timed loop (possibly padded with a few NOPs), which would consist of fewer instructions, and so would reduce the lenght of code generated.
All the REPT does is saves you having to type 'n' lots of "NOP", it doesn't change the length of the code generated, which is what is probably upsetting the compiler.
A PC relative jump will have limited (signed) range - I'm guessing you're busting this, but I don't have an AVR ASM manual to hand.
Try the calibrated loop approach.
[edit]Hmm, a quick google suggest an RJMP should have a 12 bit range, so my explanation seems unlikely. Sorry, I'm stumped.[/edit]
I get the same error when I put your code inside a for loop, but not when it's "bare" inside a function (or even an unconditional loop.) I suspect that you're exceeding the range of the conditional jumps (which are only +/-63 instructions, unlike the unconditional relative jump), and that the use of asm() confuses the compiler so that it doesn't know that things are that far away (probably a compiler bug.)