On Linux operating systems, The as command launches the GNU assembler.
Description
The as program is 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.
- Description
- Syntax
- Arch Syntax
- Options
- Alpha Options
- Arm Options
- Blackfin Options
- D10V Options
- D30V Options
- Epiphany Options
- i386 Options
- Intel 80960 Options
- IP2K Options
- M32C and M16C Options
- M32R Options
- 68000 Series Options
- PD11 Options
- PicoJava Options
- 68HC11 and 68HC12 Options
- SPARC Options
- c54x Options
- MIPS Options
- MCore Options
- PowerPC Options
- s390 Options
- TMS320C6000 Options
- TILE-Gx Options
- Xtensa Options
- Z80 Options
- Related commands
- Linux commands help
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. 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.
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 ctrl-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.
The 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.
If you are invoking as via the GNU C compiler, you can use the -Wa option to pass arguments through to the assembler. The assembler arguments must be separated from each other (and the -Wa) by commas. For example:
gcc -c -g -O -Wa,-alh,-L file.c
This passes two options to the assembler: -alh (emit a listing to standard output with high-level and assembly source) and -L (retain local symbols in the symbol table).
Usually you do not need to use this -Wa mechanism, since many compiler command-line options are automatically passed to the assembler by the compiler. You can call the GNU compiler driver with the -v option to see precisely what options it passes to each compilation pass, including the assembler.
Syntax
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] [–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 …]
Arch Syntax
AArch64:
[-EB|-EL] [-mabi=ABI]
Alpha:
[-mcpu] [-mdebug | -no-mdebug] [-replace | -noreplace] [-relax] [-g] [-Gsize] [-F] [-32addr]
ARC:
[-marc[5|6|7|8]] [-EB|-EL]
ARM:
[-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]
Blackfin:
[-mcpu=processor[-sirevision]] [-mfdpic] [-mno-fdpic] [-mnopic]
CRIS:
[–underscore | –no-underscore] [–pic] [-N] [–emulation=criself | –emulation=crisaout] [–march=v0_v10 | –march=v10 | –march=v32 | –march=common_v10_v32]
D10V:
[-O]
D30V:
[-O|-n|-N]
EPIPHANY:
[-mepiphany|-mepiphany16]
H8/300:
[-h-tick-hex]
i386:
[–32|–n32|–64] [-n] [-march=CPU[+EXTENSION…]] [-mtune=CPU]
i960:
[-ACA|-ACA_A|-ACB|-ACC|-AKA|-AKB| -AKC|-AMC] [-b] [-no-relax]
IA-64:
[-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]
IP2K:
[-mip2022|-mip2022ext]
M32C:
[-m32c|-m16c] [-relax] [-h-tick-hex]
M32R:
[–m32rx|–[no-]warn-explicit-parallel-conflicts| –W[n]p]
M680X0:
[-l] [-m68000|-m68010|-m68020|…]
M68HC11:
[-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]
MCORE:
[-jsri2bsr] [-sifilter] [-relax] [-mcpu=[210|340]]
MIPS:
[-nocpp] [-EL] [-EB] [-O[optimizationlevel]] [-g[debuglevel]] [-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] [-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] [-mmt] [-mno-mt] [-mmcu] [-mno-mcu] [-mfix7000] [-mno-fix7000] [-mfix-vr4120] [-mno-fix-vr4120] [-mfix-vr4130] [-mno-fix-vr4130] [-mdebug] [-no-mdebug] [-mpdr] [-mno-pdr]
MMIX:
[–fixed-special-register-names] [–globalize-symbols] [–gnu-syntax] [–relax] [–no-predefined-symbols] [–no-expand] [–no-merge-gregs] [-x] [–linker-allocated-gregs]
PDP11:
[-mpic|-mno-pic] [-mall] [-mno-extensions] [-mextension|-mno-extension] [-mcpu] [-mmachine]
picoJava:
[-mb|-me]
PowerPC:
[-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| -mpr4|-mpower5|-mpwr5|-mpwr5x|-mpower6|-mpwr6| -mpower7|-mpw7|-ma2|-mcell| -mspe|-mtitan|-me300|-mcom] [-many] [-maltivec|-mvsx] [-mregnames| -mno-regnames] [-mrelocatable|-mrelocatable-lib|-K PIC] [-memb] [-mlittle| -mlittle-endian|-le|-mbig|-mbig-endian|-be] [-msolaris|-mno-solaris] [-nops=count]
RX:
[-mlittle-endian|-mbig-endian] [-m32bit-ints|-m16bit-ints] [-m32bit-doubles| -m64bit-doubles]
s390:
[-m31|-m64] [-mesa|-mzarch] [-march=CPU] [-mregnames|-mno-regnames] [-mwarn-areg-zero]
SCORE:
[-EB][-EL][-FIXDD][-NWARN] [-SCORE5][-SCORE5U][-SCORE7][-SCORE3] [-march=score7] [-march=score3] [-USE_R1][-KPIC][-O0][-G num][-V]
SPARC:
[-Av6|-Av7|-Av8|-Asparclet|-Asparclite -Av8plus|-Av8plusa|-Av9|-Av9a] [-xarch=v8plus|-xarch=v8plusa] [-bump] [-32|-64]
TIC54X:
[-mcpu=54[123589]|-mcpu=54[56]lp] [-mfar-mode|-mf] [-merrors-to-file
TIC6X:
[-march=arch] [-mbig-endian|-mlittle-endian] [-mdsbt|-mno-dsbt] [-mpid=no|-mpid=near|-mpid=far] [-mpic|-mno-pic]
TILE-Gx:
[-m32|-m64][-EB][-EL]
Xtensa:
[–[no-]text-section-literals] [–[no-]absolute-literals] [–[no-]target-align] [–[no-]longcalls] [–[no-]transform] [–rename-section oldname=newname]
Z80:
[-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]
Options
ARM options
The following options are available when as is configured for the 64-bit mode of the ARM Architecture (AArch64):
-ac: omit false conditionals
-ad: omit debugging directives
-ag: include general information, like as version and options passed
-ah: include high-level source
-al: include assembly
-am: include macro expansions
-an: omit forms processing
-as: include symbols
=file: set the name of the listing file to 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.
Alpha options
The following options are available when as is configured for an Alpha processor:
ARM Options
The following options are available when as is configured for the ARM processor family:
The following processor names are recognized: 21064, “21064a”, 21066, 21068, 21164, “21164a”, “21164pc”, 21264, “21264a”, “21264b”, “ev4”, “ev5”, “lca45”, “ev5”, “ev56”, “pca56”, “ev6”, “ev67”, “ev68”. The special name “all” may be used to allow the assembler to accept instructions valid for any Alpha processor.
To support existing practice in OSF/1 with respect to “.arch”, and existing practice within MILO (the Linux ARC bootloader), the numbered processor names (e.g., 21064) enable the processor-specific PALcode instructions, while the “electro-vlasic” names (e.g., “ev4”) do not.
Blackfin Options
The following options are available when as is configured for the Blackfin processor family:
D10V Options
The following option is available when as is configured for a D10V processor:
D30V Options
The following options are available when as is configured for a D30V processor:
Epiphany Options
The following options are available when as is configured for an Epiphany processor:
i386 Options
The following options are available when as is configured for an i386 processor:
Intel 80960 Options
The following options are available when as is configured for the Intel 80960 processor:
These options are only available with the ELF object file format, and require that the necessary BFD support has been included (on a 32-bit platform you have to add –enable-64-bit-bfd to configure enable 64-bit usage and use x86-64 as target platform).
“i8086"“i186"“i286"“i386"“i486"“i586"“i686"“pentium"“pentiumpro"“pentiumii"“pentiumiii"“pentium4"“prescott"“nocona"“core"“core2"“corei7"“l1om"“k1om"“k6"“k6_2"“athlon"“opteron"“k8"“amdfam10"“bdver1"“bdver2"“bdver3"“btver1"“btver2"“generic32"“generic64”
“8087” “287” “387” “no87” “mmx” “nommx” “sse” “sse2” “sse3” “ssse3” “sse4.1” “sse4.2” “sse4” “nosse” “avx” “avx2” “adx” “rdseed” “prfchw” “noavx” “vmx” “vmfunc” “smx” “xsave” “xsaveopt” “aes” “pclmul” “fsgsbase” “rdrnd” “f16c” “bmi2” “fma” “movbe” “ept” “lzcnt” “hle” “rtm” “invpcid” “clflush” “lwp” “fma4” “xop” “syscall” “rdtscp” “3dnow” “3dnowa” “sse4a” “sse5” “svme” “abm” “padlock”
Valid CPU values are identical to the processor list of -march=CPU.
IP2K Options
The following options are available when as is configured for the Ubicom IP2K series:
M32C and M16C Options
The following options are available when as is configured for the Renesas M32C and M16C processors:
M32R Options
The following options are available when as is configured for the Renesas M32R (formerly Mitsubishi M32R) series:
68000 Series Options
The following options are available when as is configured for the Motorola 68000 series.
PD11 Options
The following options are available when as is configured for the DEC PDP-11:
PicoJava Options
The following options are available when as is configured for a picoJava processor:
68HC11 and 68HC12 Options
The following options are available when as is configured for the Motorola 68HC11 or 68HC12 series.
SPARC Options
The following options are available when as is configured for the SPARC architecture:
c54x Options
The following options are available when as is configured for the ‘c54x architecture.
-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.
MIPS Options
The following options are available when as is configured for a MIPS processor.
MCore Options
The following options are available when as is configured for an MCore processor.
PowerPC Options
The following options are available when as is configured for a PowerPC processor.
s390 Options
The following options are available when as is configured for the s390 processor family.
TMS320C6000 Options
The following options are available when as is configured for a TMS320C6000 processor.
TILE-Gx Options
The following options are available when as is configured for a TILE-Gx processor:
Xtensa Options
The following options are available when as is configured for an Xtensa processor:
Z80 Options
The following options are available when as is configured for a Z80 family processor:
Related commands
ld — Link editor for object files.