1.3. Options

Many options may be given in one of two forms: either a dash followed by a single letter, or two dashes followed by a long option name. Options are listed in alphabetical order.

1.3.1. General Options

1.3.1.1. -a arch or --arch=arch: Select target architecture

Selects the target architecture. The default architecture is x86, which supports both the IA-32 and derivatives and AMD64 instruction sets. To print a list of available architectures to standard output, use help as arch. See Section 1.4 for a list of supported architectures.

1.3.1.2. -f format or --oformat=format: Select object format

Selects the output object format. The default object format is bin, which is a flat format binary with no relocation. To print a list of available object formats to standard output, use help as format. See Section 1.6 for a list of supported object formats.

1.3.1.3. -g debug or --dformat=debug: Select debugging format

Selects the debugging format for debug information. Debugging information can be used by a debugger to associate executable code back to the source file or get data structure and type information. Available debug formats vary between different object formats; yasm will error when an invalid combination is selected. The default object format is selected by the object format. To print a list of available debugging formats to standard output, use help as debug. See Section 1.7 for a list of supported debugging formats.

1.3.1.4. -h or --help: Print a summary of options

Prints a summary of invocation options. All other options are ignored, and no output file is generated.

1.3.1.5. -L list or --lformat=list: Select list file format

Selects the format/style of the output list file. List files typically intermix the original source with the machine code generated by the assembler. The default list format is nasm, which mimics the NASM list file format. To print a list of available list file formats to standard output, use help as list.

1.3.1.6. -l listfile or --list=listfile: Specify list filename

Specifies the name of the output list file. If this option is not used, no list file is generated.

1.3.1.7. -m machine or --machine=machine: Select target machine architecture

Selects the target machine architecture. Essentially a subtype of the selected architecture, the machine type selects between major subsets of an architecture. For example, for the x86 architecture, the two available machines are x86, which is used for the IA-32 and derivative 32-bit instruction set, and amd64, which is used for the 64-bit instruction set. This differentiation is required to generate the proper object file for relocatable object formats such as COFF and ELF. To print a list of available machines for a given architecture to standard output, use help as machine and the given architecture using -a arch. See Part VI for more details.

1.3.1.8. -o filename or --objfile=filename: Specify object filename

Specifies the name of the output file, overriding any default name generated by Yasm.

1.3.1.9. -p parser or --parser=parser: Select parser

Selects the parser (the assembler syntax). The default parser is nasm, which emulates the syntax of NASM, the Netwide Assembler. Another available parser is gas, which emulates the syntax of GNU AS. To print a list of available parsers to standard output, use help as parser. See Section 1.5 for a list of supported parsers.

1.3.1.10. -r preproc or --preproc=preproc: Select preprocessor

Selects the preprocessor to use on the input file before passing it to the parser. Preprocessors often provide macro functionality that is not included in the main parser. The default preprocessor is nasm, which is an imported version of the actual NASM preprocessor. A raw preprocessor is also available, which simply skips the preprocessing step, passing the input file directly to the parser. To print a list of available preprocessors to standard output, use help as preproc.

1.3.1.11. --version: Get the Yasm version

This option causes Yasm to prints the version number of Yasm as well as a license summary to standard output. All other options are ignored, and no output file is generated.

1.3.2. Warning Options

-W options have two contrary forms: -W?name? and -Wno-name. Only the non-default forms are shown here.

The warning options are handled in the order given on the command line, so if -w is followed by -Worphan-labels, all warnings are turned off except for orphan-labels.

1.3.2.1. -w: Inhibit all warning messages

This option causes Yasm to inhibit all warning messages. As discussed above, this option may be followed by other options to re-enable specified warnings.

1.3.2.2. -Werror: Treat warnings as errors

This option causes Yasm to treat all warnings as errors. Normally warnings do not prevent an object file from being generated and do not result in a failure exit status from yasm, whereas errors do. This option makes warnings equivalent to errors in terms of this behavior.

1.3.2.3. -Wno-unrecognized-char: Do not warn on unrecognized input characters

Causes Yasm to not warn on unrecognized characters found in the input. Normally Yasm will generate a warning for any non-ASCII character found in the input file.

1.3.2.4. -Worphan-labels: Warn on labels lacking a trailing colon

When using the NASM-compatible parser, causes Yasm to warn about labels found alone on a line without a trailing colon. While these are legal labels in NASM syntax, they may be unintentional, due to typos or macro definition ordering.

1.3.2.5. -X style: Change error/warning reporting style

Selects a specific output style for error and warning messages. The default is gnu style, which mimics the output of gcc. The vc style is also available, which mimics the output of Microsoft’s Visual Studio compiler.

This option is available so that Yasm integrates more naturally into IDE environments such as Visual Studio or Emacs, allowing the IDE to correctly recognize the error/warning message as such and link back to the offending line of source code.

1.3.3. Preprocessor Options

While these preprocessor options theoretically will affect any preprocessor, the only preprocessor currently in Yasm is the nasm preprocessor.

1.3.3.1. -D macro[=value]: Pre-define a macro

Pre-defines a single-line macro. The value is optional (if no value is given, the macro is still defined, but to an empty value).

1.3.3.2. -e or --preproc-only: Only preprocess

Stops assembly after the preprocessing stage; preprocessed output is sent to the specified output name or, if no output name is specified, the standard output. No object file is produced.

1.3.3.3. -I path: Add include file path

Adds directory path to the search path for include files. The search path defaults to only including the directory in which the source file resides.

1.3.3.4. -P filename: Pre-include a file

Pre-includes file filename, making it look as though filename was prepended to the input. Can be useful for prepending multi-line macros that the -D can’t support.

1.3.3.5. -U macro: Undefine a macro

Undefines a single-line macro (may be either a built-in macro or one defined earlier in the command line with -D (see Section 1.3.3.1).