NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: kevin on February 16, 2008, 02:30:53 PM

Title: How does %include work
Post by: kevin on February 16, 2008, 02:30:53 PM
Does it just insert the text where the directive is called?
Title: Re: How does %include work
Post by: Frank Kotler on February 16, 2008, 03:50:15 PM
Correct.

%include "myfile.inc"

Will "cut and paste" the contents of "myfile.inc" at that point in the file. Nasm will look in the "current" directory for "myfile.inc". That is, if you're in /home/fbk, and type "nasm src/myfile.asm", and  "myfile.asm" includes that %include, Nasm will be looking in /home/fbk not /home/fbk/src. The "-I" switch adds search paths for %include (and incbin). "nasm -I src/ src/myfile.asm" would find it. You can make this part or all of the "NASMENV" environment variable: "set NASMENV=-I/home/fbk/src/ -I/home/fbk/include/" - or whatever your OS requires ("export ..."). Still, it can be challenging to find "nested" includes. A little common sense about where you put this stuff in the first place will help. :)

Best,
Frank