man yasm (Commandes) - The YASM Modular Assembler

NAME

yasm - The YASM Modular Assembler

SYNOPSIS

yasm [-f format] [-o outfile] [options...] [infile] yasm -h

DESCRIPTION

The YASM Modular Assembler is a portable, retargetable assembler written under the ``new'' (2 or 3 clause) BSD license. It is designed from the ground up to allow for multiple assembler syntaxes (parsers) to be supported in addition to multiple output object formats and multiple instruction sets. Another primary module of the overall design is an optimizer module.

YASM consists of the yasm command, libyasm, the core backend library, and a large number of loadable modules. On some platforms, libyasm and the loadable modules are statically built into the yasm executable rather than being dynamically loaded.

The yasm command assembles the file infile and directs output to the file outfile if specified. If outfile is not specified, yasm will derive a default output file name from the name of its input file, usually by appending .o or .obj, or by removing all extensions for a raw binary file. Failing that, the output file name will be yasm.out.

If called without an infile, yasm assembles the standard input and directs output to the file outfile, or yasm.out if no outfile is specified.

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.

The following general options are available:

--version
Prints yasm version information and license summary to standard output. All other options are ignored, and no output file is generated.
-h or --help
Prints a summary of invocation options. All other options are ignored, and no output file is generated.
-a arch or --arch=arch
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 yasm_arch(7) for more details.
-p parser or --parser=parser
Selects the parser (the assembler syntax). The default parser is ``nasm'', which emulates the syntax of NASM, the Netwide Assembler. To print a list of available parsers to standard output, use ``help'' as parser.
-r preproc or --preproc=preproc
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.
-f format or --oformat=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.
-g debug or --dformat=debug
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.
-L list or --lformat=list
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.
-o filename or --objfile=filename
Specifies the name of the output file, overriding any default name selected by yasm.
-l listfile or --list=listfile
Specifies the name of the output list file. If this option is not used, no list file is generated.
-m machine or --machine=machine
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 yasm_arch(7) for more details.

WARNING OPTIONS

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

-w
Inhibits all warning messages.
-Werror
Treats warnings as errors.
-Wno-unrecognized-char
Causes yasm to not warn on unrecognized characters found in the input.
-Worphan-labels
Causes yasm to warn about labels found alone on a line without a trailing colon. While these are legal labels in the ``nasm'' parser, they may be unintentional, due to typos or macro definition ordering.
-X style
Selects a specific output style of 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 C++ compiler.

PREPROCESSOR OPTIONS

-e or --preproc-only
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.
-I path
Adds directory path to the search path for include files.
-P filename
Pre-includes file filename, making it look as though filename was prepended to the input.
-D macro[=value]
Pre-defines a single-line macro.
-U macro
Undefines a single-line macro.

EXAMPLES

To assemble NASM syntax, 32-bit x86 source source.asm into ELF file source.o, warning on orphan labels:

yasm -f elf -Worphan-labels source.asm

To assemble NASM syntax AMD64 source x.asm into AMD64 Win32 file object.obj:

yasm -m amd64 -f win32 -o object.obj x.asm

To assemble already preprocessed NASM syntax 32-bit x86 source y.asm into flat binary file y.com:

yasm -f bin -r raw -o y.com y.asm

DIAGNOSTICS

The yasm command exits 0 on success, and nonzero if an error occurs.

COMPATIBILITY

YASM's NASM parser and preprocessor, while they strive to be as compatible as possible with NASM, have a few incompatibilities due to YASM's different internal structure.

RESTRICTIONS

As object files are often architecture and machine dependent, not all combinations of object formats, architectures, and machines are legal; trying to use an invalid combination will result in an error.

There is no support for list files or symbol maps.

Relocatable object formats are limited to static linking applications, as YASM cannot generate relocations for dynamic linking.

SEE ALSO

as(1), ld(1), nasm(1), yasm_arch(7)

BUGS

When using the ``x86'' architecture, it is overly easy to generate AMD64 code (using the BITS 64 directive) and generate a 32-bit object file (by failing to specify -m amd64 on the command line). Similarly, specifying -m amd64 does not default the BITS setting to 64.

AUTHOR

Peter Johnson <peter@tortall.net>.