A label defined in inline assembler (e.g. used ofr a tight busy loop) compiler / assembler will give an error if the inline aseembler block is inside of a for loop:
void main(void)
{
for(;;)
{
__asm
mov a,#7
asmloop:
dzsn a
goto asmloop
__endasm;
}
}
Output: build/testasmloop.asm:108: Error: undefined symbol encountered during assembly
When looking at the compiler created assembler file it looks fine (except the indentation of the label):
_main:
00102$:
; testasmloop.c: 16: __endasm;
mov a,#7
asmloop:
dzsn a
goto asmloop
goto 00102$
00104$:
; testasmloop.c: 18: }
ret
I researched a bit more and found that the problem is caused by the assembler.
The problem is caused by mixing numeric labels ( e.g. 00102$: ) with normal labels ( e.g. label: ).
The following short assembler program shows the error:
testbad.asm:
./sdaspdk13 test.asm
test.asm:4: Error: < u > undefined symbol encountered during assembly
removing test.rel
This version works fine:
testok.asm:
According to an old copy of SDCC user guide (e.g. from here: http://fivedots.coe.psu.ac.th/~cj/masd/resources/sdcc-doc/SDCCUdoc-13.html) it is not allowed to use normal labels in inline assembler (this matches exact the observed behaviour):
***All labels defined within inline assembler code HAS TO BE of the form nnnnn$ where nnnn is a number less than 100 (which implies a limit of utmost 100 inline assembler labels per function).
In contrast the current SDCC user guide (http://sdcc.sourceforge.net/doc/sdccman.pdf) does not mention this fact and also gives a BAD example (chapter 3.11):
old format:
Example
new format:
Example:
You're right that the example is bad.
But the old explanation is still there in 3.11.4 Use of Labels within Inline Assembler
Please do not assign bugs to developers. It is up to the developers to pick something up and assign it to themselves.