IFNDEF directive is maybe broken
I tried to do "header guards" by using the IFNDEF directive, but the file ends up not being included at all
Here's what I've done on the inc file:
.ifndef HEADER_NAME
HEADER_NAME = 0
; code here
.endif
Then I have included the inc file in my main file using .include "incfile.inc" and it doesn't get included.
UPDATE: Actually the problem is a bit trickier to reproduce.
What was happening in my code was that I had created a label that was referenced before its declaration. Something like this:
.include "incfile.inc" ; the file gets included here
label1:
jmp label2 ; label2 is not defined yet
label2: ; here label2 is defined
; code for label2 here
I assume the assembler supports this by reading the code multiple times. This might be happening because label1 was not assembled (due to not knowing label2 yet) and the assembler had to start over and assemble that part after knowing label2.
When starting over, the IFNDEF check does not pass, because it was defined already and so the assembler ignores that part, not including it in the binary.
The proof is that the code works normally if I declare the label before actually using it.