I have different "*.asm" files that need to be included in the "main.asm" file. The problem I'm facing is that: In many files I have declared labels like "loop", "forLoop", "whileTag" etc... in the same way ( i.e. with the same name ) And when I try to %include "file1.asm" and %include "file2.asm" it gives me a compilation error. It says that I can't declare the same label twice ( i.e. file1.asm and file2.asm, both have "loopHere" label declared ). How do I solve this ? Thanks
The problem with local labels is: Say I have
File 1:
.label1
;staff
Now file 2:
;code that uses label1
.label1 ; definition after usage
Now if I:
%include "file1.asm"
%include "file2.asm"
The resulting main.asm would be:
.label1
;staff
;code that uses label1
.label1 ; definition after usage
Code at line 3 would actually use label1 at line one and not the one at line 4
Quote from NASM Manual
A label beginning with a single period is treated as a local label, which means that it is associated with the previous non-local label.
My bad, I just realized that if I:
File 1:
file1: ; add this label
.label1
;staff
Now file 2:
file2: ; add this label
;code that uses label1
.label1 ; definition after usage
Everything works great!
Access them with:
file1.label1
file2.label1