1 .TH NASM 1 "The Netwide Assembler Project"
3 nasm \- the Netwide Assembler, a portable 80x86 assembler
28 command assembles the file
30 and directs output to the file
36 will derive a default output file name from the name of its input
37 file, usually by appending `.o' or `.obj', or by removing all
38 extensions for a raw binary file. Failing that, the output file name
45 to process options from
47 as if they were included on the command line.
52 to assemble the given input file without first applying the macro
55 .BI \-D " macro[=value]"
56 Pre-defines a single-line macro.
58 .BI \-d " macro[=value]"
66 to preprocess the given input file, and write the output to
68 (or the specified output file name), and not actually assemble
72 Specifies the output file format. To see a list of valid output
80 to generate debug information in selected format
85 to exit immediately, after giving a summary of its invocation
91 , but also lists all valid output formats.
94 Adds a directory to the search path for include files. The directory
95 specification must include the trailing slash, as it will be
96 directly prepended to the name of the include file.
104 Causes an assembly listing to be directed to the given file, in
105 which the original source is displayed on the right hand side (plus
106 the source for included files and the expansions of multi-line
107 macros) and the generated code is shown in hex on the left.
112 to output Makefile-style dependencies to stdout; normal output is
118 but assumes that missing Makefile dependecies are generated and added
119 to dependency list without a prefix.
122 Output Makefile-style dependencies to the specified file.
125 Same as a combination of
132 Override the default name of the dependency target
133 dependency target name. This is normally the same
134 as the output filename, specified by the
141 except it tries to quote characters that have special
142 meaning in Makefile syntax. This is not foolproof,
143 as not all characters with special meaning are quotable
150 Optimize branch offsets.
156 :Minimal optimization
159 :Multipass optimization (default)
162 Specifies a precise name for the output file, overriding
164 default means of determining it.
167 Specifies a file to be pre-included, before the main source file
168 starts to be processed.
178 to exit immediately, after displaying its version number.
184 to send its error messages and/or help text to
192 to assemble in SciTech TASM compatible mode
195 Undefines a single-line macro.
205 to exit immediately, after displaying its version number.
210 to enable or disable certain classes of warning messages, for
217 specifies error reporting format (gnu or vc).
222 to redirect error messages to
224 This option exists to support operating systems on which stderr is not
230 Prepend or append (respectively) the given argument to all
231 global or extern variables.
235 This man page does not fully describe the syntax of
237 assembly language, but does give a summary of the differences from
241 have no leading `%' sign, unlike
243 and floating-point stack registers are referred to as
248 .I Floating-point instructions
249 may use either the single-operand form or the double. A
251 keyword is provided; thus, one could either write
259 or one could use the alternative single-operand forms
267 .I Uninitialised storage
268 is reserved using the
276 pseudo-opcodes, each taking one parameter which gives the number of
277 bytes, words, doublewords, quadwords or ten-byte words to reserve.
280 of data items is not done by the
282 keyword as seen in DOS assemblers, but by the use of the
288 message: times 3 db 'abc'
291 times 64-$+message db 0
293 which defines the string `abcabcabc', followed by the right number
294 of zero bytes to make the total length up to 64 bytes.
297 are always understood to be immediate (i.e. the address of the
298 symbol), unless square brackets are used, in which case the contents
299 of the memory location are used. Thus:
304 loads AX with the address of the variable `wordvar', whereas
313 mov ax,[es:wordvar+bx]
317 of memory locations. The syntaxes
320 mov ax,es:wordvar[bx]
325 are not legal at all, although the use of a segment register name as
326 an instruction prefix is valid, and can be used with instructions
329 which can't be overridden any other way.
332 may be expressed numerically in most formats: a trailing H, Q or B
333 denotes hex, octal or binary respectively, and a leading `0x' or `$'
334 denotes hex as well. Leading zeros are not treated specially at all.
335 Character constants may be enclosed in single or double quotes;
336 there is no escape character. The ordering is little-endian
337 (reversed), so that the character constant
339 denotes 0x64636261 and not 0x61626364.
342 begin with a period, and their `locality' is granted by the
343 assembler prepending the name of the previous non-local symbol. Thus
344 declaring a label `.loop' after a label `label' has actually defined
345 a symbol called `label.loop'.
352 to direct all following code to the named section. Section names
353 vary with output file format, although most formats support the
359 (The exception is the
361 format, in which all segments are user-definable.)
366 to position its notional assembly point at an absolute address: so
367 no code or data may be generated, but you can use
372 to move the assembly point further on, and you can define labels. So
373 this directive may be used to define data structures. When you have
374 finished doing absolute assembly, you must issue another
376 directive to return to normal assembly.
382 switches the default processor mode for which
384 is generating code: it is equivalent to
393 import and export symbol definitions, respectively, from and to
394 other modules. Note that the
396 directive must appear before the definition of the symbol it refers
402 when used to bracket a number of
405 or similar instructions, define a data structure. In addition to
406 defining the offsets of the structure members, the construct also
407 defines a symbol for the size of the structure, which is simply the
410 tacked on to the end.
411 .SS FORMAT-SPECIFIC DIRECTIVES
415 flat-form binary output format, and specifies the address at which
416 the output code will eventually be loaded.
418 .I GROUP grpname seg1 seg2...
421 (Microsoft 16-bit) output format, and defines segment groups. This
424 which directs that all segment, group and symbol names output to the
425 object file should be in uppercase. Note that the actual assembly is
426 still case sensitive.
431 output format, and causes a dependency record to be written to the
432 output file which indicates that the program requires a certain
433 library in order to run.
434 .SS MACRO PREPROCESSOR
435 Single-line macros are defined using the
439 commands, in a similar fashion to the C preprocessor. They can be
440 overloaded with respect to number of parameters, although defining a
441 macro with no parameters prevents the definition of any macro with
442 the same name taking parameters, and vice versa.
444 defines macros whose names match case-sensitively, whereas
446 defines case-insensitive macros.
448 Multi-line macros are defined using
452 (the distinction is the same as that between
456 whose syntax is as follows:
461 .IR minprm [- maxprm "][+][.nolist] [" defaults ]
464 <some lines of macro expansion text>
469 Again, these macros may be overloaded. The trailing plus sign
470 indicates that any parameters after the last one get subsumed, with
471 their separating commas, into the last parameter. The
473 part can be used to specify defaults for unspecified macro
477 is a valid synonym for
480 To refer to the macro parameters within a macro expansion, you use
483 and so on. You can also enforce that a macro parameter should
484 contain a condition code by using
486 and you can invert the condition code by using
488 You can also define a label specific to a macro invocation by
489 prefixing it with a double % sign.
491 Files can be included using the
493 directive, which works like C.
495 The preprocessor has a `context stack', which may be used by one
496 macro to store information that a later one will retrieve. You can
497 push a context on the stack using
501 and change the name of the top context (without disturbing any
502 associated definitions) using
506 macros specific to the top context may be defined by prefixing their
507 names with %$, and things specific to the next context down with
510 Conditional assembly is done by means of
516 as in C. (Except that
518 can accept several putative macro names, and will evaluate TRUE if
519 any of them is defined.) In addition, the directives
523 can be used to condition on the name of the top context on the
524 context stack. The obvious set of `else-if' directives,
532 Please report bugs through the bug tracker function at http://nasm.sourceforge.org.