[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here is a brief summary of how to invoke as
. For details,
see Command-Line Options.
as [-a[cdghlns][=file]] [--alternate] [-D] [--compress-debug-sections] [--nocompress-debug-sections] [--debug-prefix-map old=new] [--defsym sym=val] [-f] [-g] [--gstabs] [--gstabs+] [--gdwarf-2] [--gdwarf-sections] [--help] [-I dir] [-J] [-K] [-L] [--listing-lhs-width=NUM] [--listing-lhs-width2=NUM] [--listing-rhs-width=NUM] [--listing-cont-lines=NUM] [--keep-locals] [-o objfile] [-R] [--reduce-memory-overheads] [--statistics] [-v] [-version] [--version] [-W] [--warn] [--fatal-warnings] [-w] [-x] [-Z] [@FILE] [--size-check=[error|warning]] [--target-help] [target-options] [--|files ...] Target Alpha options: [-mcpu] [-mdebug | -no-mdebug] [-replace | -noreplace] [-relax] [-g] [-Gsize] [-F] [-32addr] Target ARC options: [-marc[5|6|7|8]] [-EB|-EL] Target ARM options: [-mcpu=processor[+extension...]] [-march=architecture[+extension...]] [-mfpu=floating-point-format] [-mfloat-abi=abi] [-meabi=ver] [-mthumb] [-EB|-EL] [-mapcs-32|-mapcs-26|-mapcs-float| -mapcs-reentrant] [-mthumb-interwork] [-k] Target Blackfin options: [-mcpu=processor[-sirevision]] [-mfdpic] [-mno-fdpic] [-mnopic] Target CRIS options: [--underscore | --no-underscore] [--pic] [-N] [--emulation=criself | --emulation=crisaout] [--march=v0_v10 | --march=v10 | --march=v32 | --march=common_v10_v32] Target D10V options: [-O] Target D30V options: [-O|-n|-N] Target EPIPHANY options: [-mepiphany|-mepiphany16] Target H8/300 options: [-h-tick-hex] Target i386 options: [--32|--x32|--64] [-n] [-march=CPU[+EXTENSION...]] [-mtune=CPU] Target i960 options: [-ACA|-ACA_A|-ACB|-ACC|-AKA|-AKB| -AKC|-AMC] [-b] [-no-relax] Target IA-64 options: [-mconstant-gp|-mauto-pic] [-milp32|-milp64|-mlp64|-mp64] [-mle|mbe] [-mtune=itanium1|-mtune=itanium2] [-munwind-check=warning|-munwind-check=error] [-mhint.b=ok|-mhint.b=warning|-mhint.b=error] [-x|-xexplicit] [-xauto] [-xdebug] Target IP2K options: [-mip2022|-mip2022ext] Target M32C options: [-m32c|-m16c] [-relax] [-h-tick-hex] Target M32R options: [--m32rx|--[no-]warn-explicit-parallel-conflicts| --W[n]p] Target M680X0 options: [-l] [-m68000|-m68010|-m68020|...] Target M68HC11 options: [-m68hc11|-m68hc12|-m68hcs12|-mm9s12x|-mm9s12xg] [-mshort|-mlong] [-mshort-double|-mlong-double] [--force-long-branches] [--short-branches] [--strict-direct-mode] [--print-insn-syntax] [--print-opcodes] [--generate-example] Target MCORE options: [-jsri2bsr] [-sifilter] [-relax] [-mcpu=[210|340]] Target MICROBLAZE options: Target MIPS options: [-nocpp] [-EL] [-EB] [-O[optimization level]] [-g[debug level]] [-G num] [-KPIC] [-call_shared] [-non_shared] [-xgot [-mvxworks-pic] [-mabi=ABI] [-32] [-n32] [-64] [-mfp32] [-mgp32] [-march=CPU] [-mtune=CPU] [-mips1] [-mips2] [-mips3] [-mips4] [-mips5] [-mips32] [-mips32r2] [-mips64] [-mips64r2] [-construct-floats] [-no-construct-floats] [-mnan=encoding] [-trap] [-no-break] [-break] [-no-trap] [-mips16] [-no-mips16] [-mmicromips] [-mno-micromips] [-msmartmips] [-mno-smartmips] [-mips3d] [-no-mips3d] [-mdmx] [-no-mdmx] [-mdsp] [-mno-dsp] [-mdspr2] [-mno-dspr2] [-mmsa] [-mno-msa] [-mmt] [-mno-mt] [-mmcu] [-mno-mcu] [-minsn32] [-mno-insn32] [-mfix7000] [-mno-fix7000] [-mfix-rm7000] [-mno-fix-rm7000] [-mfix-vr4120] [-mno-fix-vr4120] [-mfix-vr4130] [-mno-fix-vr4130] [-mdebug] [-no-mdebug] [-mpdr] [-mno-pdr] Target MMIX options: [--fixed-special-register-names] [--globalize-symbols] [--gnu-syntax] [--relax] [--no-predefined-symbols] [--no-expand] [--no-merge-gregs] [-x] [--linker-allocated-gregs] Target PDP11 options: [-mpic|-mno-pic] [-mall] [-mno-extensions] [-mextension|-mno-extension] [-mcpu] [-mmachine] Target picoJava options: [-mb|-me] Target PowerPC options: [-a32|-a64] [-mpwrx|-mpwr2|-mpwr|-m601|-mppc|-mppc32|-m603|-m604|-m403|-m405| -m440|-m464|-m476|-m7400|-m7410|-m7450|-m7455|-m750cl|-mppc64| -m620|-me500|-e500x2|-me500mc|-me500mc64|-me5500|-me6500|-mppc64bridge| -mbooke|-mpower4|-mpwr4|-mpower5|-mpwr5|-mpwr5x|-mpower6|-mpwr6| -mpower7|-mpwr7|-mpower8|-mpwr8|-ma2|-mcell|-mspe|-mtitan|-me300|-mcom] [-many] [-maltivec|-mvsx|-mhtm|-mvle] [-mregnames|-mno-regnames] [-mrelocatable|-mrelocatable-lib|-K PIC] [-memb] [-mlittle|-mlittle-endian|-le|-mbig|-mbig-endian|-be] [-msolaris|-mno-solaris] [-nops=count] Target RX options: [-mlittle-endian|-mbig-endian] [-m32bit-doubles|-m64bit-doubles] [-muse-conventional-section-names] [-msmall-data-limit] [-mpid] [-mrelax] [-mint-register=number] [-mgcc-abi|-mrx-abi] Target s390 options: [-m31|-m64] [-mesa|-mzarch] [-march=CPU] [-mregnames|-mno-regnames] [-mwarn-areg-zero] Target SCORE options: [-EB][-EL][-FIXDD][-NWARN] [-SCORE5][-SCORE5U][-SCORE7][-SCORE3] [-march=score7][-march=score3] [-USE_R1][-KPIC][-O0][-G num][-V] Target SPARC options: [-Av6|-Av7|-Av8|-Asparclet|-Asparclite -Av8plus|-Av8plusa|-Av9|-Av9a] [-xarch=v8plus|-xarch=v8plusa] [-bump] [-32|-64] Target TIC54X options: [-mcpu=54[123589]|-mcpu=54[56]lp] [-mfar-mode|-mf] [-merrors-to-file <filename>|-me <filename>] Target TIC6X options: [-march=arch] [-mbig-endian|-mlittle-endian] [-mdsbt|-mno-dsbt] [-mpid=no|-mpid=near|-mpid=far] [-mpic|-mno-pic] Target TILE-Gx options: [-m32|-m64][-EB][-EL] Target Xtensa options: [--[no-]text-section-literals] [--[no-]absolute-literals] [--[no-]target-align] [--[no-]longcalls] [--[no-]transform] [--rename-section oldname=newname] Target Z80 options: [-z80] [-r800] [ -ignore-undocumented-instructions] [-Wnud] [ -ignore-unportable-instructions] [-Wnup] [ -warn-undocumented-instructions] [-Wud] [ -warn-unportable-instructions] [-Wup] [ -forbid-undocumented-instructions] [-Fud] [ -forbid-unportable-instructions] [-Fup] |
@file
Options in file are separated by whitespace. A whitespace character may be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to be included with a backslash. The file may itself contain additional @file options; any such options will be processed recursively.
-a[cdghlmns]
-ac
-ad
-ag
-ah
-al
-am
-an
-as
=file
You may combine these options; for example, use `-aln' for assembly listing without forms processing. The `=file' option, if used, must be the last one. By itself, `-a' defaults to `-ahls'.
--alternate
.altmacro
.
--compress-debug-sections
--nocompress-debug-sections
-D
--debug-prefix-map old=new
--defsym sym=value
.set
pseudo-op.
-f
-g
--gen-debug
--gstabs
--gstabs+
--gdwarf-2
--gdwarf-sections
--size-check=error
--size-check=warning
--help
--target-help
-I dir
.include
directives.
-J
-K
-L
--keep-locals
--listing-lhs-width=number
--listing-lhs-width2=number
--listing-rhs-width=number
--listing-cont-lines=number
-o objfile
as
objfile.
-R
Set the default size of GAS's hash tables to a prime number close to number. Increasing this value can reduce the length of time it takes the assembler to perform its tasks, at the expense of increasing the assembler's memory requirements. Similarly reducing this value can reduce the memory requirements at the expense of speed.
--reduce-memory-overheads
--statistics
--strip-local-absolute
-v
-version
as
version.
--version
as
version and exit.
-W
--no-warn
--fatal-warnings
--warn
-w
-x
-Z
-- | files ...
See section 9.1.2 Options, for the options available when as is configured for an Alpha processor.
The following options are available when as is configured for an ARC processor.
-marc[5|6|7|8]
-EB | -EL
The following options are available when as is configured for the ARM processor family.
-mcpu=processor[+extension...]
-march=architecture[+extension...]
-mfpu=floating-point-format
-mfloat-abi=abi
-mthumb
-mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant
-EB | -EL
-mthumb-interwork
-k
See section 9.5.1 Options, for the options available when as is configured for the Blackfin processor family.
See the info pages for documentation of the CRIS-specific options.
The following options are available when as is configured for a D10V processor.
-O
The following options are available when as is configured for a D30V processor.
-O
-n
-N
The following options are available when as is configured for the Adapteva EPIPHANY series.
See section 9.10.1 Options, for the options available when as is configured for an Epiphany processor.
See section 9.14.1 Options, for the options available when as is configured for an i386 processor.
The following options are available when as is configured for the Intel 80960 processor.
-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
-b
-no-relax
The following options are available when as is configured for the Ubicom IP2K series.
-mip2022ext
-mip2022
The following options are available when as is configured for the Renesas M32C and M16C processors.
-m32c
-m16c
-relax
-h-tick-hex
The following options are available when as is configured for the Renesas M32R (formerly Mitsubishi M32R) series.
--m32rx
--warn-explicit-parallel-conflicts or --Wp
--no-warn-explicit-parallel-conflicts or --Wnp
The following options are available when as is configured for the Motorola 68000 series.
-l
-m68000 | -m68008 | -m68010 | -m68020 | -m68030
| -m68040 | -m68060 | -m68302 | -m68331 | -m68332
| -m68333 | -m68340 | -mcpu32 | -m5200
-m68881 | -m68882 | -mno-68881 | -mno-68882
-m68851 | -mno-68851
For details about the PDP-11 machine dependent features options, see 9.29.1 Options.
-mpic | -mno-pic
-mall
-mall-extensions
-mno-extensions
-mextension | -mno-extension
-mcpu
-mmachine
The following options are available when as is configured for a picoJava processor.
The following options are available when as is configured for the Motorola 68HC11 or 68HC12 series.
-m68hc11 | -m68hc12 | -m68hcs12 | -mm9s12x | -mm9s12xg
--xgate-ramoffset
-mshort
-mlong
-mshort-double
-mlong-double
--force-long-branches
-S | --short-branches
--strict-direct-mode
--print-insn-syntax
--print-opcodes
--generate-example
as
.
The following options are available when as
is configured
for the SPARC architecture:
-Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite
-Av8plus | -Av8plusa | -Av9 | -Av9a
`-Av8plus' and `-Av8plusa' select a 32 bit environment. `-Av9' and `-Av9a' select a 64 bit environment.
`-Av8plusa' and `-Av9a' enable the SPARC V9 instruction set with UltraSPARC extensions.
-xarch=v8plus | -xarch=v8plusa
-bump
The following options are available when as is configured for the 'c54x architecture.
-mfar-mode
-mcpu=CPU_VERSION
-merrors-to-file FILENAME
The following options are available when as is configured for a MIPS processor.
-G num
gp
register. It is only accepted for targets that
use ECOFF format, such as a DECstation running Ultrix. The default value is 8.
-EB
-EL
-mips1
-mips2
-mips3
-mips4
-mips5
-mips32
-mips32r2
-mips64
-mips64r2
-march=cpu
-mtune=cpu
-mfix7000
-mno-fix7000
-mfix-rm7000
-mno-fix-rm7000
-mdebug
-no-mdebug
-mpdr
-mno-pdr
.pdr
sections.
-mgp32
-mfp32
-mips16
-no-mips16
.set mips16
at the start of the assembly file. `-no-mips16'
turns off this option.
-mmicromips
-mno-micromips
.set micromips
at the start of the assembly file. `-mno-micromips'
turns off this option. This is equivalent to putting .set nomicromips
at the start of the assembly file.
-msmartmips
-mno-smartmips
.set smartmips
at the start of the assembly file.
`-mno-smartmips' turns off this option.
-mips3d
-no-mips3d
-mdmx
-no-mdmx
-mdsp
-mno-dsp
-mdspr2
-mno-dspr2
-mmsa
-mno-msa
-mmt
-mno-mt
-mmcu
-mno-mcu
-minsn32
-mno-insn32
.set insn32
at
the start of the assembly file. `-mno-insn32' turns off this
option. This is equivalent to putting .set noinsn32
at the
start of the assembly file. By default `-mno-insn32' is
selected, allowing all instructions to be used.
--construct-floats
--no-construct-floats
--relax-branch
--no-relax-branch
-mnan=encoding
--emulation=name
The available configuration names are: `mipself', `mipslelf' and `mipsbelf'. Choosing `mipself' now has no effect, since the output is always ELF. `mipslelf' and `mipsbelf' select little- and big-endian output respectively, but `-EL' and `-EB' are now the preferred options instead.
-nocpp
as
ignores this option. It is accepted for compatibility with
the native tools.
--trap
--no-trap
--break
--no-break
-n
as
will issue a warning every
time it generates a nop instruction from a macro.
The following options are available when as is configured for an MCore processor.
-jsri2bsr
-nojsri2bsr
-sifilter
-nosifilter
-relax
-mcpu=[210|340]
-EB
-EL
See the info pages for documentation of the MMIX-specific options.
See section 9.31.1 Options, for the options available when as is configured for a PowerPC processor.
See the info pages for documentation of the RX-specific options.
The following options are available when as is configured for the s390 processor family.
-m31
-m64
-mesa
-mzarch
-march=processor
-mregnames
-mno-regnames
-mwarn-areg-zero
See section 9.40.1 TIC6X Options, for the options available when as is configured for a TMS320C6000 processor.
See section 9.41.1 Options, for the options available when as is configured for a TILE-Gx processor.
See section 9.48.1 Command Line Options, for the options available when as is configured for an Xtensa processor.
The following options are available when as is configured for a Z80 family processor.
-z80
-r800
-ignore-undocumented-instructions
-Wnud
-ignore-unportable-instructions
-Wnup
-warn-undocumented-instructions
-Wud
-warn-unportable-instructions
-Wup
-forbid-undocumented-instructions
-Fud
-forbid-unportable-instructions
-Fup
1.1 Structure of this Manual 1.2 The GNU Assembler 1.3 Object File Formats 1.4 Command Line 1.5 Input Files 1.6 Output (Object) File 1.7 Error and Warning Messages
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This manual is intended to describe what you need to know to use
GNU as
. We cover the syntax expected in source files, including
notation for symbols, constants, and expressions; the directives that
as
understands; and of course how to invoke as
.
This manual also describes some of the machine-dependent features of various flavors of the assembler.
On the other hand, this manual is not intended as an introduction to programming in assembly language--let alone programming in general! In a similar vein, we make no attempt to introduce the machine architecture; we do not describe the instruction set, standard mnemonics, registers or addressing modes that are standard to a particular architecture. You may want to consult the manufacturer's machine architecture manual for this information.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GNU as
is really a family of assemblers.
If you use (or have used) the GNU assembler on one architecture, you
should find a fairly similar environment when you use it on another
architecture. Each version has much in common with the others,
including object file formats, most assembler directives (often called
pseudo-ops) and assembler syntax.
as
is primarily intended to assemble the output of the
GNU C compiler gcc
for use by the linker
ld
. Nevertheless, we've tried to make as
assemble correctly everything that other assemblers for the same
machine would assemble.
Any exceptions are documented explicitly (see section 9. Machine Dependent Features).
This doesn't mean as
always uses the same syntax as another
assembler for the same architecture; for example, we know of several
incompatible versions of 680x0 assembly language syntax.
Unlike older assemblers, as
is designed to assemble a source
program in one pass of the source file. This has a subtle impact on the
.org directive (see section .org
).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The GNU assembler can be configured to produce several alternative
object file formats. For the most part, this does not affect how you
write assembly language programs; but directives for debugging symbols
are typically different in different file formats. See section Symbol Attributes.
On the machine specific, as
can be configured to produce either
b.out
or COFF format object files.
On the machine specific, as
can be configured to produce either
SOM or ELF format object files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
After the program name as
, the command line may contain
options and file names. Options may appear in any order, and may be
before, after, or between file names. The order of file names is
significant.
`--' (two hyphens) by itself names the standard input file
explicitly, as one of the files for as
to assemble.
Except for `--' any command line argument that begins with a
hyphen (`-') is an option. Each option changes the behavior of
as
. No option changes the way another option works. An
option is a `-' followed by one or more letters; the case of
the letter is important. All options are optional.
Some options expect exactly one file name to follow them. The file name may either immediately follow the option's letter (compatible with older assemblers) or it may be the next command argument (GNU standard). These two command lines are equivalent:
as -o my-object-file.o mumble.s as -omy-object-file.o mumble.s |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
We use the phrase source program, abbreviated source, to
describe the program input to one run of as
. The program may
be in one or more files; how the source is partitioned into files
doesn't change the meaning of the source.
The source program is a concatenation of the text in all the files, in the order specified.
Each time you run as
it assembles exactly one source
program. The source program is made up of one or more files.
(The standard input is also a file.)
You give as
a command line that has zero or more input file
names. The input files are read (from left file name to right). A
command line argument (in any position) that has no special meaning
is taken to be an input file name.
If you give as
no file names it attempts to read one input file
from the as
standard input, which is normally your terminal. You
may have to type ctl-D to tell as
there is no more program
to assemble.
Use `--' if you need to explicitly name the standard input file in your command line.
If the source is empty, as
produces a small, empty object
file.
There are two ways of locating a line in the input file (or files) and either may be used in reporting error messages. One way refers to a line number in a physical file; the other refers to a line number in a "logical" file. See section Error and Warning Messages.
Physical files are those files named in the command line given
to as
.
Logical files are simply names declared explicitly by assembler
directives; they bear no relation to physical files. Logical file names help
error messages reflect the original source file, when as
source
is itself synthesized from other files. as
understands the
`#' directives emitted by the gcc
preprocessor. See also
.file
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Every time you run as
it produces an output file, which is
your assembly language program translated into numbers. This file
is the object file. Its default name is
a.out
.
b.out
when as
is configured for the Intel 80960.
You can give it another name by using the `-o' option. Conventionally,
object file names end with `.o'. The default name is used for historical
reasons: older assemblers were capable of assembling self-contained programs
directly into a runnable program. (For some formats, this isn't currently
possible, but it can be done for the a.out
format.)
The object file is meant for input to the linker ld
. It contains
assembled program code, information to help ld
integrate
the assembled program into a runnable file, and (optionally) symbolic
information for the debugger.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
as
may write warnings and error messages to the standard error
file (usually your terminal). This should not happen when a compiler
runs as
automatically. Warnings report an assumption made so
that as
could keep assembling a flawed program; errors report a
grave problem that stops the assembly.
Warning messages have the format
file_name:NNN:Warning Message Text |
(where NNN is a line number). If a logical file name has been given
(see section .file
) it is used for the filename, otherwise the name of
the current input file is used. If a logical line number was given
(see section .line
)
then it is used to calculate the number printed,
otherwise the actual line in the current source file is printed. The
message text is intended to be self explanatory (in the grand Unix
tradition).
Error messages have the format
file_name:NNN:FATAL:Error Message Text |
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |