YASM(1) | The Yasm Modular Assembler | YASM(1) |
NAME
yasm - The Yasm Modular Assembler
SYNOPSIS
yasm [-f format] [-o outfile] [other options...] {infile}
yasm -h
DESCRIPTION
The Yasm Modular Assembler is a portable, retargetable assembler written under the “new” (2 or 3 clause) BSD license. Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes, outputs binary, ELF32, ELF64, COFF, Win32, and Win64 object formats, and generates source debugging information in STABS, DWARF 2, and CodeView 8 formats.
YASM consists of the yasm command, libyasm, the core backend library, and a large number of modules. Currently, libyasm and the loadable modules are statically built into the yasm executable.
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 with an infile of “-”, 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. Options are listed in alphabetical order.
General Options
-a arch or --arch=arch: Select target architecture
-f format or --oformat=format: Select object format
-g debug or --dformat=debug: Select debugging format
-L list or --lformat=list: Select list file format
-l listfile or --list=listfile: Specify list filename
-m machine or --machine=machine: Select target machine architecture
-o filename or --objfile=filename: Specify object filename
-p parser or --parser=parser: Select parser
-r preproc or --preproc=preproc: Select preprocessor
-h or --help: Print a summary of options
--version: Get the Yasm version
Warning Options
-W options have two contrary forms: -Wname 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.
-w: Inhibit all warning messages
-Werror: Treat warnings as errors
-Wno-unrecognized-char: Do not warn on unrecognized input characters
-Worphan-labels: Warn on labels lacking a trailing option
-X style: Change error/warning reporting style
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.
Preprocessor Options
While these preprocessor options theoretically will affect any preprocessor, the only preprocessor currently in Yasm is the “nasm” preprocessor.
-D macro[=value]: Pre-define a macro
-e or --preproc-only: Only preprocess
-I path: Add include file path
-P filename: Pre-include a file
-U macro: Undefine a macro
EXAMPLES
To assemble NASM syntax, 32-bit x86 source source.asm into ELF file source.o, warning on orphan labels:
yasm -f elf32 -Worphan-labels source.asm
To assemble NASM syntax AMD64 source x.asm into Win64 file object.obj:
yasm -f win64 -o object.obj x.asm
To assemble already preprocessed NASM syntax 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.
Yasm´s GAS parser and preprocessor are missing a number of features present in GNU AS.
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 symbol maps.
SEE ALSO
yasm_arch(7), yasm_dbgfmts(7), yasm_objfmts(7), yasm_parsers(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 or selecting a 64-bit object format such as ELF64 on the command line).
AUTHOR
Peter Johnson <peter@tortall.net>
COPYRIGHT
Copyright © 2004, 2005, 2006, 2007 Peter Johnson
April 2007 | Yasm |