2.1.14 The −Z Option: Send Errors to a File
Under MS−DOS it can be difficult (though there are ways) to redirect the standard−error output of a program
to a file. Since NASM usually produces its warning and error messages on stderr, this can make it hard to
capture the errors if (for example) you want to load them into an editor.
NASM therefore provides the −Z option, taking a filename argument which causes errors to be sent to the
specified files rather than standard error. Therefore you can redirect the errors into a file by typing
nasm −Z myfile.err −f obj myfile.asm
In earlier versions of NASM, this option was called −E, but it was changed since −E is an option
conventionally used for preprocessing only, with disastrous results. See section 2.1.20.
2.1.15 The −s Option: Send Errors to stdout
The −s option redirects error messages to stdout rather than stderr, so it can be redirected under
MS−DOS. To assemble the file myfile.asm and pipe its output to the more program, you can type:
nasm −s −f obj myfile.asm | more
See also the −Z option, section 2.1.14.
2.1.16 The −i Option: Include File Search Directories
When NASM sees the %include or %pathsearch directive in a source file (see section 4.6.1, section
4.6.2 or section 3.2.3), it will search for the given file not only in the current directory, but also in any
directories specified on the command line by the use of the −i option. Therefore you can include files from a
macro library, for example, by typing
nasm −ic:\macrolib\ −f obj myfile.asm
(As usual, a space between −i and the path name is allowed, and optional).
NASM, in the interests of complete source−code portability, does not understand the file naming conventions
of the OS it is running on; the string you provide as an argument to the −i option will be prepended exactly as
written to the name of the include file. Therefore the trailing backslash in the above example is necessary.
Under Unix, a trailing forward slash is similarly necessary.
(You can use this to your advantage, if you’re really perverse, by noting that the option −ifoo will cause
%include "bar.i" to search for the file foobar.i...)
If you want to define a standard include search path, similar to /usr/include on Unix systems, you
should place one or more −i directives in the NASMENV environment variable (see section 2.1.28).
For Makefile compatibility with many C compilers, this option can also be specified as −I.
2.1.17 The −p Option: Pre−Include a File
NASM allows you to specify files to be pre−included into your source file, by the use of the −p option. So
running
nasm myfile.asm −p myinc.inc
is equivalent to running nasm myfile.asm and placing the directive %include "myinc.inc" at the
start of the file.
For consistency with the −I, −D and −U options, this option can also be specified as −P.
2.1.18 The −d Option: Pre−Define a Macro
Just as the −p option gives an alternative to placing %include directives at the start of a source file, the −d
option gives an alternative to placing a %define directive. You could code
20