Sortix 1.1dev ports manual
This manual documents Sortix 1.1dev ports. You can instead view this document in the latest official manual.
NASM(1) | The Netwide Assembler Project | NASM(1) |
NAME
nasm - the Netwide Assembler, a portable 80x86 assemblerSYNOPSIS
nasm [-@ response file] [-f format] [-o outfile] [-l listfile] [options...] filenameDESCRIPTION
The nasm command assembles the file filename and directs output to the file outfile if specified. If outfile is not specified, nasm 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 ‘nasm.out’.OPTIONS
-@ filenameCauses nasm to process options from
filename as if they were included on the command line.
-a
Causes nasm to assemble the given input
file without first applying the macro preprocessor.
-D|-d macro[=value]
Pre-defines a single-line macro.
-E|-e
Causes nasm to preprocess the given
input file, and write the output to stdout (or the specified output
file name), and not actually assemble anything.
-f format
Specifies the output file format. To see a
list of valid output formats, use the -hf option.
-F format
Specifies the debug information format. To see
a list of valid output formats, use the -y option (for example -felf
-y).
-g
Causes nasm to generate debug
information in selected format.
-h
Causes nasm to exit immediately, after
giving a summary of its invocation options.
-hf
Same as -h , but also lists all valid
output formats.
-I|-i directory
Adds a directory to the search path for
include files. The directory specification must include the trailing slash, as
it will be directly prepended to the name of the include file.
-l listfile
Causes an assembly listing to be directed to
the given file, in which the original source is displayed on the right hand
side (plus the source for included files and the expansions of multi-line
macros) and the generated code is shown in hex on the left.
-M
Causes nasm to output Makefile-style
dependencies to stdout; normal output is suppressed.
-MG file
Same as -M but assumes that missing
Makefile dependecies are generated and added to dependency list without a
prefix.
-MF file
Output Makefile-style dependencies to the
specified file.
-MD file
Same as a combination of -M and
-MF options.
-MT file
Override the default name of the dependency
target dependency target name. This is normally the same as the output
filename, specified by the -o option.
-MQ file
The same as -MT except it tries to
quote characters that have special meaning in Makefile syntax. This is not
foolproof, as not all characters with special meaning are quotable in
Make.
-MP
Emit phony target.
-O number
Optimize branch offsets.
-o outfile
•-O0: No optimization
•-O1: Minimal optimization
•-Ox: Multipass optimization
(default)
Specifies a precise name for the output file,
overriding nasm's default means of determining it.
-P|-p file
Specifies a file to be pre-included, before
the main source file starts to be processed.
-s
Causes nasm to send its error messages
and/or help text to stdout instead of stderr.
-t
Causes nasm to assemble in SciTech TASM
compatible mode.
-U|-u macro
Undefines a single-line macro.
-v
Causes nasm to exit immediately, after
displaying its version number.
*-W[no-]foo'
Causes nasm to enable or disable
certain classes of warning messages, in gcc-like style, for example
-Worphan-labels or -Wno-orphan-labels.
-w[+-]foo
Causes nasm to enable or disable
certain classes of warning messages, for example -w+orphan-labels or
-w-macro-params.
-X format
Specifies error reporting format (gnu or
vc).
-y
Causes nasm to list supported debug
formats.
-Z filename
Causes nasm to redirect error messages
to filename. This option exists to support operating systems on which
stderr is not easily redirected.
--prefix, --postfix
Prepend or append (respectively) the given
argument to all global or extern variables.
SYNTAX
This man page does not fully describe the syntax of nasm's assembly language, but does give a summary of the differences from other assemblers.fadd st0,st1 fadd st1,st0
fadd st1 fadd to st1
message: times 3 db 'abc' times 64-$+message db 0
mov ax,wordvar
mov ax,[wordvar] mov ax,[wordvar+1] mov ax,[es:wordvar+bx]
mov ax,es:wordvar[bx] es mov ax,wordvar[1]
DIRECTIVES
SECTION name or SEGMENT name causes nasm to direct all following code to the named section. Section names vary with output file format, although most formats support the names .text, .data and .bss. (The exception is the obj format, in which all segments are user-definable.)FORMAT-SPECIFIC DIRECTIVES
ORG address is used by the bin flat-form binary output format, and specifies the address at which the output code will eventually be loaded.MACRO PREPROCESSOR
Single-line macros are defined using the %define or %idefine commands, in a similar fashion to the C preprocessor. They can be overloaded with respect to number of parameters, although defining a macro with no parameters prevents the definition of any macro with the same name taking parameters, and vice versa. %define defines macros whose names match case-sensitively, whereas %idefine defines case-insensitive macros.%macro name minprm[-maxprm][+][.nolist] [defaults] <some lines of macro expansion text> %endmacro
BUGS
Please report bugs through the bug tracker function at http://nasm.us.SEE ALSO
as(1), ld(1).02/19/2014 | NASM |