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
116 optimize branch offsets (-O0 disables, default).
119 Specifies a precise name for the output file, overriding
121 default means of determining it.
124 Specifies a file to be pre-included, before the main source file
125 starts to be processed.
135 to exit immediately, after displaying its version number.
141 to send its error messages and/or help text to
149 to assemble in SciTech TASM compatible mode
152 Undefines a single-line macro.
162 to exit immediately, after displaying its version number.
167 to enable or disable certain classes of warning messages, for
174 specifies error reporting format (gnu or vc).
179 to redirect error messages to
181 This option exists to support operating systems on which stderr is not
186 This man page does not fully describe the syntax of
188 assembly language, but does give a summary of the differences from
192 have no leading `%' sign, unlike
194 and floating-point stack registers are referred to as
199 .I Floating-point instructions
200 may use either the single-operand form or the double. A
202 keyword is provided; thus, one could either write
210 or one could use the alternative single-operand forms
218 .I Uninitialised storage
219 is reserved using the
227 pseudo-opcodes, each taking one parameter which gives the number of
228 bytes, words, doublewords, quadwords or ten-byte words to reserve.
231 of data items is not done by the
233 keyword as seen in DOS assemblers, but by the use of the
239 message: times 3 db 'abc'
242 times 64-$+message db 0
244 which defines the string `abcabcabc', followed by the right number
245 of zero bytes to make the total length up to 64 bytes.
248 are always understood to be immediate (i.e. the address of the
249 symbol), unless square brackets are used, in which case the contents
250 of the memory location are used. Thus:
255 loads AX with the address of the variable `wordvar', whereas
264 mov ax,[es:wordvar+bx]
268 of memory locations. The syntaxes
271 mov ax,es:wordvar[bx]
276 are not legal at all, although the use of a segment register name as
277 an instruction prefix is valid, and can be used with instructions
280 which can't be overridden any other way.
283 may be expressed numerically in most formats: a trailing H, Q or B
284 denotes hex, octal or binary respectively, and a leading `0x' or `$'
285 denotes hex as well. Leading zeros are not treated specially at all.
286 Character constants may be enclosed in single or double quotes;
287 there is no escape character. The ordering is little-endian
288 (reversed), so that the character constant
290 denotes 0x64636261 and not 0x61626364.
293 begin with a period, and their `locality' is granted by the
294 assembler prepending the name of the previous non-local symbol. Thus
295 declaring a label `.loop' after a label `label' has actually defined
296 a symbol called `label.loop'.
303 to direct all following code to the named section. Section names
304 vary with output file format, although most formats support the
310 (The exception is the
312 format, in which all segments are user-definable.)
317 to position its notional assembly point at an absolute address: so
318 no code or data may be generated, but you can use
323 to move the assembly point further on, and you can define labels. So
324 this directive may be used to define data structures. When you have
325 finished doing absolute assembly, you must issue another
327 directive to return to normal assembly.
333 switches the default processor mode for which
335 is generating code: it is equivalent to
344 import and export symbol definitions, respectively, from and to
345 other modules. Note that the
347 directive must appear before the definition of the symbol it refers
353 when used to bracket a number of
356 or similar instructions, define a data structure. In addition to
357 defining the offsets of the structure members, the construct also
358 defines a symbol for the size of the structure, which is simply the
361 tacked on to the end.
362 .SS FORMAT-SPECIFIC DIRECTIVES
366 flat-form binary output format, and specifies the address at which
367 the output code will eventually be loaded.
369 .I GROUP grpname seg1 seg2...
372 (Microsoft 16-bit) output format, and defines segment groups. This
375 which directs that all segment, group and symbol names output to the
376 object file should be in uppercase. Note that the actual assembly is
377 still case sensitive.
382 output format, and causes a dependency record to be written to the
383 output file which indicates that the program requires a certain
384 library in order to run.
385 .SS MACRO PREPROCESSOR
386 Single-line macros are defined using the
390 commands, in a similar fashion to the C preprocessor. They can be
391 overloaded with respect to number of parameters, although defining a
392 macro with no parameters prevents the definition of any macro with
393 the same name taking parameters, and vice versa.
395 defines macros whose names match case-sensitively, whereas
397 defines case-insensitive macros.
399 Multi-line macros are defined using
403 (the distinction is the same as that between
407 whose syntax is as follows:
412 .IR minprm [- maxprm "][+][.nolist] [" defaults ]
415 <some lines of macro expansion text>
420 Again, these macros may be overloaded. The trailing plus sign
421 indicates that any parameters after the last one get subsumed, with
422 their separating commas, into the last parameter. The
424 part can be used to specify defaults for unspecified macro
428 is a valid synonym for
431 To refer to the macro parameters within a macro expansion, you use
434 and so on. You can also enforce that a macro parameter should
435 contain a condition code by using
437 and you can invert the condition code by using
439 You can also define a label specific to a macro invocation by
440 prefixing it with a double % sign.
442 Files can be included using the
444 directive, which works like C.
446 The preprocessor has a `context stack', which may be used by one
447 macro to store information that a later one will retrieve. You can
448 push a context on the stack using
452 and change the name of the top context (without disturbing any
453 associated definitions) using
457 macros specific to the top context may be defined by prefixing their
458 names with %$, and things specific to the next context down with
461 Conditional assembly is done by means of
467 as in C. (Except that
469 can accept several putative macro names, and will evaluate TRUE if
470 any of them is defined.) In addition, the directives
474 can be used to condition on the name of the top context on the
475 context stack. The obvious set of `else-if' directives,
483 Please report bugs through the bug tracker function at http://nasm.sourceforge.org.