3 .\" Author: Peter Johnson <peter@tortall.net>
4 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
6 .\" Manual: The Yasm Modular Assembler
10 .TH "YASM" "1" "April 2007" "Yasm" "The Yasm Modular Assembler"
11 .\" -----------------------------------------------------------------
12 .\" * set default formatting
13 .\" -----------------------------------------------------------------
14 .\" disable hyphenation
16 .\" disable justification (adjust text to left margin only)
18 .\" -----------------------------------------------------------------
19 .\" * MAIN CONTENT STARTS HERE *
20 .\" -----------------------------------------------------------------
22 yasm \- The Yasm Modular Assembler
25 \fByasm\fR [\fB\-f\ \fR\fB\fIformat\fR\fR] [\fB\-o\ \fR\fB\fIoutfile\fR\fR] [\fB\fIother\ options\fR\fR...] {\fIinfile\fR}
30 The Yasm Modular Assembler is a portable, retargetable assembler written under the
32 (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\&.
36 command, libyasm, the core backend library, and a large number of modules\&. Currently, libyasm and the loadable modules are statically built into the
42 command assembles the file infile and directs output to the file
48 will derive a default output file name from the name of its input file, usually by appending
51 \&.obj, or by removing all extensions for a raw binary file\&. Failing that, the output file name will be
59 assembles the standard input and directs output to the file
67 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\&.
70 \fB\-a \fR\fB\fIarch\fR\fR or \fB\-\-arch=\fR\fB\fIarch\fR\fR: Select target architecture
72 Selects the target architecture\&. The default architecture is
73 \(lqx86\(rq, which supports both the IA\-32 and derivatives and AMD64 instruction sets\&. To print a list of available architectures to standard output, use
78 for a list of supported architectures\&.
81 \fB\-f \fR\fB\fIformat\fR\fR or \fB\-\-oformat=\fR\fB\fIformat\fR\fR: Select object format
83 Selects the output object format\&. The default object format is
84 \(lqbin\(rq, which is a flat format binary with no relocation\&. To print a list of available object formats to standard output, use
89 for a list of supported object formats\&.
92 \fB\-g \fR\fB\fIdebug\fR\fR or \fB\-\-dformat=\fR\fB\fIdebug\fR\fR: Select debugging format
94 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;
96 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
100 \fByasm_dbgfmts\fR(7)
101 for a list of supported debugging formats\&.
104 \fB\-L \fR\fB\fIlist\fR\fR or \fB\-\-lformat=\fR\fB\fIlist\fR\fR: Select list file format
106 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
107 \(lqnasm\(rq, which mimics the NASM list file format\&. To print a list of available list file formats to standard output, use
113 \fB\-l \fR\fB\fIlistfile\fR\fR or \fB\-\-list=\fR\fB\fIlistfile\fR\fR: Specify list filename
115 Specifies the name of the output list file\&. If this option is not used, no list file is generated\&.
118 \fB\-m \fR\fB\fImachine\fR\fR or \fB\-\-machine=\fR\fB\fImachine\fR\fR: Select target machine architecture
120 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
122 architecture, the two available machines are
123 \(lqx86\(rq, which is used for the IA\-32 and derivative 32\-bit instruction set, and
124 \(lqamd64\(rq, 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
128 and the given architecture using
129 \fB\-a \fR\fB\fIarch\fR\fR\&. See
134 \fB\-o \fR\fB\fIfilename\fR\fR or \fB\-\-objfile=\fR\fB\fIfilename\fR\fR: Specify object filename
136 Specifies the name of the output file, overriding any default name generated by Yasm\&.
139 \fB\-p \fR\fB\fIparser\fR\fR or \fB\-\-parser=\fR\fB\fIparser\fR\fR: Select parser
141 Selects the parser (the assembler syntax)\&. The default parser is
142 \(lqnasm\(rq, which emulates the syntax of NASM, the Netwide Assembler\&. Another available parser is
143 \(lqgas\(rq, which emulates the syntax of GNU AS\&. To print a list of available parsers to standard output, use
147 \fByasm_parsers\fR(7)
148 for a list of supported parsers\&.
151 \fB\-r \fR\fB\fIpreproc\fR\fR or \fB\-\-preproc=\fR\fB\fIpreproc\fR\fR: Select preprocessor
153 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
154 \(lqnasm\(rq, which is an imported version of the actual NASM preprocessor\&. A
156 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
162 \fB\-h\fR or \fB\-\-help\fR: Print a summary of options
164 Prints a summary of invocation options\&. All other options are ignored, and no output file is generated\&.
167 \fB\-\-version\fR: Get the Yasm version
169 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\&.
171 .SS "Warning Options"
174 options have two contrary forms:
175 \fB\-W\fR\fB\fIname\fR\fR
177 \fB\-Wno\-\fR\fB\fIname\fR\fR\&. Only the non\-default forms are shown here\&.
179 The warning options are handled in the order given on the command line, so if
182 \fB\-Worphan\-labels\fR, all warnings are turned off
184 for orphan\-labels\&.
186 \fB\-w\fR: Inhibit all warning messages
188 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\&.
191 \fB\-Werror\fR: Treat warnings as errors
193 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
194 \fByasm\fR, whereas errors do\&. This option makes warnings equivalent to errors in terms of this behavior\&.
197 \fB\-Wno\-unrecognized\-char\fR: Do not warn on unrecognized input characters
199 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\&.
202 \fB\-Worphan\-labels\fR: Warn on labels lacking a trailing option
204 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\&.
207 \fB\-X \fR\fB\fIstyle\fR\fR: Change error/warning reporting style
209 Selects a specific output style for error and warning messages\&. The default is
211 style, which mimics the output of
214 style is also available, which mimics the output of Microsoft\'s Visual C++ compiler\&.
216 This option is available so that Yasm integrates more naturally into IDE environments such as
219 Emacs, allowing the IDE to correctly recognize the error/warning message as such and link back to the offending line of source code\&.
221 .SS "Preprocessor Options"
223 While these preprocessor options theoretically will affect any preprocessor, the only preprocessor currently in Yasm is the
227 \fB\-D \fR\fB\fImacro[=value]\fR\fR: Pre\-define a macro
229 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)\&.
232 \fB\-e\fR or \fB\-\-preproc\-only\fR: Only preprocess
234 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\&.
237 \fB\-I \fR\fB\fIpath\fR\fR: Add include file path
241 to the search path for include files\&. The search path defaults to only including the directory in which the source file resides\&.
244 \fB\-P \fR\fB\fIfilename\fR\fR: Pre\-include a file
247 \fIfilename\fR, making it look as though
249 was prepended to the input\&. Can be useful for prepending multi\-line macros that the
254 \fB\-U \fR\fB\fImacro\fR\fR: Undefine a macro
256 Undefines a single\-line macro (may be either a built\-in macro or one defined earlier in the command line with
261 To assemble NASM syntax, 32\-bit x86 source
264 source\&.o, warning on orphan labels:
270 yasm \-f elf32 \-Worphan\-labels source\&.asm
276 To assemble NASM syntax AMD64 source
285 yasm \-f win64 \-o object\&.obj x\&.asm
291 To assemble already preprocessed NASM syntax x86 source
293 into flat binary file
300 yasm \-f bin \-r raw \-o y\&.com y\&.asm
309 command exits 0 on success, and nonzero if an error occurs\&.
312 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\&.
314 Yasm\'s GAS parser and preprocessor are missing a number of features present in GNU AS\&.
317 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\&.
319 There is no support for symbol maps\&.
323 \fByasm_dbgfmts\fR(7),
324 \fByasm_objfmts\fR(7),
325 \fByasm_parsers\fR(7)
335 architecture, it is overly easy to generate AMD64 code (using the
337 directive) and generate a 32\-bit object file (by failing to specify
339 or selecting a 64\-bit object format such as ELF64 on the command line)\&.
342 \fBPeter Johnson\fR <\&peter@tortall\&.net\&>
348 Copyright \(co 2004, 2005, 2006, 2007 Peter Johnson