1 .TH NASM 1 "The Netwide Assembler Project"
3 nasm \- the Netwide Assembler \- portable 80x86 assembler
22 command assembles the file
24 and directs output to the file
30 will derive a default output file name from the name of its input
31 file, usually by appending `.o' or `.obj', or by removing all
32 extensions for a raw binary file. Failing that, the output file name
39 to exit immediately, after giving a summary of its invocation
40 options, and listing all its supported output file formats.
45 to assemble the given input file without first applying the macro
51 to preprocess the given input file, and write the output to
53 (or the specified output file name), and not actually assemble
59 to output Makefile-style dependencies to stdout; normal output is
65 to redirect error messages to
67 This option exists to support operating systems on which stderr is not
73 to exit immediately, after displaying its version number.
76 Specifies the output file format. Formats include
78 to produce flat-form binary files, and
82 to produce Linux a.out and ELF object files, respectively.
85 Specifies a precise name for the output file, overriding
87 default means of determining it.
90 Causes an assembly listing to be directed to the given file, in
91 which the original source is displayed on the right hand side (plus
92 the source for included files and the expansions of multi-line
93 macros) and the generated code is shown in hex on the left.
98 to send its error messages and/or help text to
106 to enable or disable certain classes of warning messages, for
111 to, respectively, enable warnings about labels alone on lines or
112 disable warnings about incorrect numbers of parameters in macro
116 Adds a directory to the search path for include files. The directory
117 specification must include the trailing slash, as it will be
118 directly prepended to the name of the include file.
126 Specifies a file to be pre-included, before the main source file
127 starts to be processed.
134 .BI \-D " macro[=value]"
135 Pre-defines a single-line macro.
137 .BI \-d " macro[=value]"
143 Undefines a single-line macro.
152 This man page does not fully describe the syntax of
154 assembly language, but does give a summary of the differences from
158 have no leading `%' sign, unlike
160 and floating-point stack registers are referred to as
165 .I Floating-point instructions
166 may use either the single-operand form or the double. A
168 keyword is provided; thus, one could either write
176 or one could use the alternative single-operand forms
184 .I Uninitialised storage
185 is reserved using the
192 pseudo-opcodes, each taking one parameter which gives the number of
193 bytes, words, doublewords, quadwords or ten-byte words to reserve.
196 of data items is not done by the
198 keyword as seen in DOS assemblers, but by the use of the
204 message: times 3 db 'abc'
207 times 64-$+message db 0
209 which defines the string `abcabcabc', followed by the right number
210 of zero bytes to make the total length up to 64 bytes.
213 are always understood to be immediate (i.e. the address of the
214 symbol), unless square brackets are used, in which case the contents
215 of the memory location are used. Thus:
220 loads AX with the address of the variable `wordvar', whereas
229 mov ax,[es:wordvar+bx]
233 of memory locations. The syntaxes
236 mov ax,es:wordvar[bx]
241 are not legal at all, although the use of a segment register name as
242 an instruction prefix is valid, and can be used with instructions
245 which can't be overridden any other way.
248 may be expressed numerically in most formats: a trailing H, Q or B
249 denotes hex, octal or binary respectively, and a leading `0x' or `$'
250 denotes hex as well. Leading zeros are not treated specially at all.
251 Character constants may be enclosed in single or double quotes;
252 there is no escape character. The ordering is little-endian
253 (reversed), so that the character constant
255 denotes 0x64636261 and not 0x61626364.
258 begin with a period, and their `locality' is granted by the
259 assembler prepending the name of the previous non-local symbol. Thus
260 declaring a label `.loop' after a label `label' has actually defined
261 a symbol called `label.loop'.
268 to direct all following code to the named section. Section names
269 vary with output file format, although most formats support the
275 (The exception is the
277 format, in which all segments are user-definable.)
282 to position its notional assembly point at an absolute address: so
283 no code or data may be generated, but you can use
288 to move the assembly point further on, and you can define labels. So
289 this directive may be used to define data structures. When you have
290 finished doing absolute assembly, you must issue another
292 directive to return to normal assembly.
297 switches the default processor mode for which
299 is generating code: it is equivalent to
308 import and export symbol definitions, respectively, from and to
309 other modules. Note that the
311 directive must appear before the definition of the symbol it refers
317 when used to bracket a number of
320 or similar instructions, define a data structure. In addition to
321 defining the offsets of the structure members, the construct also
322 defines a symbol for the size of the structure, which is simply the
325 tacked on to the end.
326 .SS FORMAT-SPECIFIC DIRECTIVES
330 flat-form binary output format, and specifies the address at which
331 the output code will eventually be loaded.
333 .I GROUP grpname seg1 seg2...
336 (Microsoft 16-bit) output format, and defines segment groups. This
339 which directs that all segment, group and symbol names output to the
340 object file should be in uppercase. Note that the actual assembly is
341 still case sensitive.
346 output format, and causes a dependency record to be written to the
347 output file which indicates that the program requires a certain
348 library in order to run.
349 .SS MACRO PREPROCESSOR
350 Single-line macros are defined using the
354 commands, in a similar fashion to the C preprocessor. They can be
355 overloaded with respect to number of parameters, although defining a
356 macro with no parameters prevents the definition of any macro with
357 the same name taking parameters, and vice versa.
359 defines macros whose names match case-sensitively, whereas
361 defines case-insensitive macros.
363 Multi-line macros are defined using
367 (the distinction is the same as that between
371 whose syntax is as follows:
376 .IR minprm [- maxprm "][+][.nolist] [" defaults ]
379 <some lines of macro expansion text>
384 Again, these macros may be overloaded. The trailing plus sign
385 indicates that any parameters after the last one get subsumed, with
386 their separating commas, into the last parameter. The
388 part can be used to specify defaults for unspecified macro
392 is a valid synonym for
395 To refer to the macro parameters within a macro expansion, you use
398 and so on. You can also enforce that a macro parameter should
399 contain a condition code by using
401 and you can invert the condition code by using
403 You can also define a label specific to a macro invocation by
404 prefixing it with a double % sign.
406 Files can be included using the
408 directive, which works like C.
410 The preprocessor has a `context stack', which may be used by one
411 macro to store information that a later one will retrieve. You can
412 push a context on the stack using
416 and change the name of the top context (without disturbing any
417 associated definitions) using
421 macros specific to the top context may be defined by prefixing their
422 names with %$, and things specific to the next context down with
425 Conditional assembly is done by means of
431 as in C. (Except that
433 can accept several putative macro names, and will evaluate TRUE if
434 any of them is defined.) In addition, the directives
438 can be used to condition on the name of the top context on the
439 context stack. The obvious set of `else-if' directives,
447 There is a reported seg-fault on some (Linux) systems with some
448 large source files. This appears to be very hard to reproduce. All
451 bugs have been fixed...
453 There is no support for listing files, symbol maps, or debugging
454 object-file records. The advanced features of the ELF and Win32
455 object file formats are not supported, and there is no means for
456 warning the programmer against using an instruction beyond the
457 capability of the target processor.