AS - the portable GNU assembler.
| Use Case | Command | Description |
|---|---|---|
| Assemble a source file | as -o output.o input.s | đ§Š Assemble one or more input files into an object file |
| Assemble with debug info | as -g -o output.o input.s | đ Generate debugging information (STABS, DWARF, etc.) |
| Generate listing with assembly | as -alh -o output.o input.s | đ Output a listing to stdout with high-level and assembly source |
| Specify target architecture | as -march=armv8-a -o output.o input.s | đ¯ Restrict instructions to a specific architecture |
| Define a symbol value | as --defsym sym=0x100 -o output.o input.s | đĸ Define a symbol before assembly |
| Compress debug sections | as --compress-debug-sections -o output.o input.s | đī¸ Compress DWARF debug sections with zlib |
| Read options from file | as @options.txt | đ Read command-line options from a file |
| Fast assembly (skip preprocessing) | as -f -o output.o input.s | ⥠Assume source is compiler output, skip whitespace/comment preprocessing |
| Keep local symbols | as -L -o output.o input.s | đˇī¸ Retain local symbols (e.g., .L labels) in symbol table |
| Generate position-independent code (RISC-V/ARC) | as -fpic -o output.o input.s | đ Generate PIC code |
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-<N>] [--gdwarf-sections]
[--gdwarf-cie-version=VERSION]
[--help] [-I dir] [-J]
[-K] [-L] [--listing-lhs-width=NUM]
[--listing-lhs-width2=NUM] [--listing-rhs-width=NUM]
[--listing-cont-lines=NUM] [--keep-locals]
[--no-pad-sections]
[-o objfile] [-R]
[--statistics]
[-v] [-version] [--version]
[-W] [--warn] [--fatal-warnings] [-w] [-x]
[-Z] [@FILE]
[--sectname-subst] [--size-check=[error|warning]]
[--elf-stt-common=[no|yes]]
[--generate-missing-build-notes=[no|yes]]
[--multibyte-handling=[allow|warn|warn-sym-only]]
[--target-help] [target-options]
[--|files ...]
-EB|-EL â Big-endian or little-endian output-mabi=ABI â ABI: ilp32 or lp64 (default lp64)-mcpu=processor[+extension...] â Target processor (e.g., cortex-a53)-march=architecture[+extension...] â Target architecture (e.g., armv8-a)-mverbose-error / -mno-verbose-error â Enable/disable verbose error messages-mcpu â Target processor (e.g., 21064, ev4)-mdebug / -no-mdebug â Enable/disable .mdebug encapsulation-relax â Force all relocations into object file-replace / -noreplace â Enable/disable procedure call optimization (VMS)-g â Debug info pass-through-Gsize â Threshold for .sbss placement-F, -32addr â Ignored for compatibility-mcpu=cpu â Core processor variant-EB|-EL â Big-endian or little-endian-mcode-density â Enable Code Density extension-mcpu=processor[+extension...] â Target processor-march=architecture[+extension...] â Target architecture-mfpu=floating-point-format â FPU architecture-mfloat-abi=abi â Floating-point ABI-mthumb â Thumb-only instruction decoding-mapcs-32|-mapcs-26|-mapcs-float|-mapcs-reentrant â Procedure calling convention-EB|-EL â Endianness-mthumb-interwork â Thumb/ARM interworking-mccs â CodeComposer Studio compatibility-k â PIC code-mcpu=processor[-sirevision] â Target processor (e.g., bf533)-mfdpic â FDPIC ABI-mno-fdpic / -mnopic â Disable FDPIC-EB â Big-endian eBPF-EL â Little-endian eBPF (default: host endianness)--underscore | --no-underscore--pic-N--emulation=criself | --emulation=crisaout--march=v0_v10 | --march=v10 | --march=v32 | --march=common_v10_v32-march=archname â Architecture-mcpu=cpuname â CPU-EL / -mlittle-endian â Little-endian-EB / -mbig-endian â Big-endian-fpic / -pic â Position-independent code-mljump / -mno-ljump â Transform short branch to jmpi-mbranch-stub / -mno-branch-stub â Pass PCI relocations for bsr-force2bsr / -mforce2bsr / -no-force2bsr / -mno-force2bsr â Transform jbsr to bsr-jsri2bsr / -mjsri2bsr / -no-jsri2bsr / -mno-jsri2bsr â Transform jsri to bsr-mnolrw / -mno-lrw â Transform lrw to movih/ori-melrw / -mno-elrw â Extended lrw instructions-mlaf / -mliterals-after-func / -mno-laf / -mno-literals-after-func â Literal pool placement after functions-mlabr / -mliterals-after-br / -mno-labr / -mnoliterals-after-br â Literal pool after unconditional branches-mistack / -mno-istack â Interrupt stack instructions-mhard-float â Hard float-mmp â Multiprocessor instructions-mcp â Coprocessor instructions-mcache â Cache prefetch-msecurity â Security instructions-mtrust â Trust instructions-mdsp â DSP instructions-medsp â Enhanced DSP-mvdsp â Vector DSP-O-O|-n|-N-mepiphany â Allow both 32 and 16 bit instructions (default)-mepiphany16 â Restrict to 16 bit instructions-h-tick-hex â Support H'00 hex constants-mach=name â Machine variant (h8300h, h8300s, etc.)--32|--x32|--64 â Word size (32-bit, x32, 64-bit)-n â Disable multi-byte NOP optimization--divide â Treat '/' as normal character (not comment)-march=CPU[+EXTENSION...] â Target processor + extensions-mtune=CPU â Optimize for specific CPU-msse2avx â Encode SSE with VEX prefix-muse-unaligned-vector-move â Encode aligned moves as unaligned-msse-check=none|warning|error â Check SSE instructions-mavxscalar=128|256 â Scalar AVX vector length-mvexwig=0|1 â VEX.W-ignored encoding-mevexlig=128|256|512 â LIG EVEX vector length-mevexwig=0|1 â WIG EVEX encoding-mmnemonic=att|intel â Instruction mnemonic syntax-msyntax=att|intel â Instruction syntax-mnaked-reg â Register names without % prefix-madd-bnd-prefix â Add BND prefix to all branches-mno-shared â Optimize for non-PLT (ELF)-mbig-obj â Big object file format (PE/COFF)-momit-lock-prefix=no|yes â Omit lock prefix-mfence-as-lock-add=no|yes â Encode fences as lock add-mrelax-relocations=no|yes â Generate relax relocations-malign-branch-boundary=NUM â Align branches within NUM byte boundary-malign-branch=TYPE[+TYPE...] â Types of branches to align-malign-branch-prefix-size=NUM â Max prefixes for alignment-mbranches-within-32B-boundaries â Align branches within 32B-mlfence-after-load=no|yes â Lfence after load-mlfence-before-indirect-branch=none|all|register|memory â Lfence before indirect branch-mlfence-before-ret=none|shl|or|yes|not â Lfence before ret-mx86-used-note=no|yes â Generate GNU property notes-mevexrcig=rne|rd|ru|rz â SAE-only EVEX RC bits-mamd64| -mintel64 â Accept only AMD64 or Intel64 ISA-O0|-O|-O1|-O2|-Os â Optimize instruction encoding-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-mip2022ext â Extended IP2022 instructions-mip2022 â Basic IP2022 only-m32c â M32C instructions-m16c â M16C instructions (default)-relax â Link-time relaxations-h-tick-hex â H'00 hex constants--m32rx â M32RX target--warn-explicit-parallel-conflicts or --Wp â Warn on questionable parallel constructs--no-warn-explicit-parallel-conflicts or --Wnp â No warnings-l â Shorten references to undefined symbols-m68000|-m68008|-m68010|-m68020|-m68030|-m68040|-m68060|-m68302|-m68331|-m68332|-m68333|-m68340|-mcpu32|-m5200 â Target processor-m68881|-m68882|-mno-68881|-mno-68882 â Floating-point coprocessor-m68851|-mno-68851 â MMU coprocessor-m68hc11|-m68hc12|-m68hcs12|-mm9s12x|-mm9s12xg â Target-mshort|-mlong â Short or long pointers-mshort-double|-mlong-double â Double size--force-long-branches--short-branches--strict-direct-mode--print-insn-syntax--print-opcodes--generate-example-jsri2bsr-sifilter-relax-mcpu=[210|340]-mcpu=meta (e.g., metac11, metac12, metac21)-mfpu=meta (e.g., metac21)-mdsp (DSP)No specific options listed in this man page.
-nocpp â Ignored-EL|-EB â Endianness-O[optimization level]-g[debug level]-G num â GP-relative threshold-KPIC, -call_shared, -non_shared, -xgot, -mvxworks-pic-mabi=ABI â ABI (32, n32, 64, etc.)-mfp32|-mgp32|-mfp64|-mgp64|-mfpxx â Register width-modd-spreg|-mno-odd-spreg â Odd single-precision registers-march=CPU â Target CPU-mtune=CPU â Tune for CPU-mips1 through -mips64r6 â ISA level-mips16|-no-mips16 â MIPS16 mode-mmips16e2|-mno-mips16e2 â MIPS16e2-mmicromips|-mno-micromips â microMIPS-msmartmips|-mno-smartmips â SmartMIPS-mips3d|-no-mips3d â MIPS-3D-mdmx|-no-mdmx â MDMX-mdsp|-mno-dsp â DSP R1-mdspr2|-mno-dspr2 â DSP R2-mdspr3|-mno-dspr3 â DSP R3-mmsa|-mno-msa â MSA-mxpa|-mno-xpa â XPA-mmt|-mno-mt â MT-mmcu|-mno-mcu â MCU-mcrc|-mno-crc â CRC-mginv|-mno-ginv â GINV-mloongson-mmi|-mno-loongson-mmi â Loongson MMI-mloongson-cam|-mno-loongson-cam â Loongson CAM-mloongson-ext|-mno-loongson-ext â Loongson EXT-mloongson-ext2|-mno-loongson-ext2 â Loongson EXT2-minsn32|-mno-insn32 â 32-bit only encodings (microMIPS)-mfix7000|-mno-fix7000 â NOPs for mfhi/mflo-mfix-rm7000|-mno-fix-rm7000 â NOPs for dmult/dmultu-mfix-r5900|-mno-fix-r5900 â R5900 short loop workaround-mdebug|-no-mdebug â .mdebug section-mpdr|-mno-pdr â .pdr sections--construct-floats|--no-construct-floats â Float constant construction--relax-branch|--no-relax-branch â Branch relaxation-mignore-branch-isa|-mno-ignore-branch-isa â Branch ISA mode checks-mnan=encoding â NaN encoding (2008 or legacy)--emulation=name â Output format (little effect)--trap|--no-trap|--break|--no-break â Overflow/division handling-n â Warn on macro-generated nops--fixed-special-register-names--globalize-symbols--gnu-syntax--relax--no-predefined-symbols--no-expand--no-merge-gregs-x--linker-allocated-gregs-relax-all â Replace all out-of-range branches/calls with jmp/callr-relax-section â Replace out-of-range branches with PC-relative jmp when possible (default)-no-relax â No replacement-EB|-EL â Endianness (default little)-march=architecture â (r1, r2; default r1)-EL|-EB â Endianness-O â Optimize for performance-Os â Optimize for space-mcpu=cpu-misa=isa-mabi=abi (v1, v2, v2fp, v2fpp)-mall-ext â Enable all extensions-m[no-]16-bit â 16-bit extension-m[no-]perf-ext-m[no-]perf2-ext-m[no-]string-ext-m[no-]dsp-ext-m[no-]mac-m[no-]div-m[no-]audio-isa-ext-m[no-]fpu-sp-ext-m[no-]fpu-dp-ext-m[no-]fpu-fma-mfpu-freg=FREG (0-3)-mreduced-regs-mfull-regs-m[no-]dx-regs-mpic-mno-relax-mb2bb â Back-to-back branch optimization-mpic|-mno-pic-mall-mno-extensions-mextension|-mno-extension-mcpu-mmachine-mb|-me-a32|-a64 â ELF32/XCOFF32 or ELF64/XCOFF64-K PIC â Set EF_PPC_RELOCATABLE_LIB-mpwrx|-mpwr2|-mpwr|-m601|-mppc|-mppc32|-m603|-m604|-m403|-m405|-m440|-m464|-m476|-m7400|-m7410|-m7450|-m7455|-m750cl|-mgekko|-mbroadway|-mppc64|-m620|-me500|-e500x2|-me500mc|-me500mc64|-me5500|-me6500|-mppc64bridge|-mbooke|-mpower4|-mpwr4|-mpower5|-mpwr5|-mpwr5x|-mpower6|-mpwr6|-mpower7|-mpwr7|-mpower8|-mpwr8|-mpower9|-mpwr9|-mpower10|-mpwr10|-ma2|-mcell|-mspe|-mspe2|-mtitan|-me300|-mcom â Target processor/architecture-many â Accept any architecture-maltivec|-mvsx|-mhtm|-mvle â Enable specific extensions-mregnames|-mno-regnames â Allow symbolic register names-mrelocatable|-mrelocatable-lib|-K PIC â Relocatable support-memb â Set PPC_EMB bit-mlittle|-mlittle-endian|-le|-mbig|-mbig-endian|-be â Endianness-msolaris|-mno-solaris â Solaris code generation-nops=count â Branch if alignment inserts more than count nops-link-relax â Assume linker optimizes LDI32-mnolink-relax â Do not assume-mno-warn-regname-label â Suppress register name label warnings-fpic|-fPIC|-fno-pic â Position-independent code-march=ISA â Base ISA (e.g., rv32ima)-mabi=ABI â ABI (ilp32, lp64, etc.)-mlittle-endian|-mbig-endian â Endianness-mrelax â Enable linker relaxations (default)-mno-relax â Disable-march-attr â Generate RISC-V ELF attribute section-mno-arch-attr â Do not generate-mcsr-check â Enable CSR checking-mno-csr-check â Disable-misa-spec=ISAspec â ISA spec version-mpriv-spec=PRIVspec â Privileged spec version-mg10-m32bit-doubles|-m64bit-doubles-mlittle-endian|-mbig-endian-m32bit-doubles|-m64bit-doubles-muse-conventional-section-names-msmall-data-limit-mpid-mrelax-mint-register=number-mgcc-abi|-mrx-abi-m31|-m64 â Word size (31/32 or 64 bits)-mesa|-mzarch â Architecture mode (ESA or z/Architecture)-march=CPU â Processor (g5, g6, z900, etc.)-mregnames|-mno-regnames â Symbolic register names-mwarn-areg-zero â Warn if base/index register operand evaluates to zero-EB|-EL-FIXDD-NWARN-SCORE5|-SCORE5U|-SCORE7|-SCORE3-march=score7|-march=score3-USE_R1-KPIC-O0-G num-V-Av6|-Av7|-Av8|-Aleon|-Asparclet|-Asparclite -Av8plus|-Av8plusa|-Av8plusb|-Av8plusc|-Av8plusd -Av8plusv|-Av8plusm|-Av9|-Av9a|-Av9b|-Av9c -Av9d|-Av9e|-Av9v|-Av9m|-Asparc|-Asparcvis -Asparcvis2|-Asparcfmaf|-Asparcima|-Asparcvis3 -Asparcvisr|-Asparc5 â Architecture-xarch=... â Alternative architecture specification-bump-32|-64 â Word size--enforce-aligned-data--dcti-couples-detect-mcpu=54[123589]|-mcpu=54[56]lp-mfar-mode|-mf-merrors-to-file <filename>|-me <filename>-march=arch (c62x, c64x, c64x+, c67x, c67x+, c674x)-mbig-endian|-mlittle-endian-mdsbt|-mno-dsbt â DSBT addressing-mpid=no|near|far â PID addressing-mpic|-mno-pic â PIC addressing-m32|-m64 â Word size-EB|-EL â Endianness-mtune=arch (mcm24, mcm, gr5, gr6)--[no-]text-section-literals â Literal pool placement--[no-]auto-litpools â Automatic literal pools--[no-]absolute-literals â L32R addressing mode--[no-]target-align â Automatic alignment--[no-]longcalls â Call transformation--[no-]transform â All transformations--rename-section oldname=newname--[no-]trampolines â Jump transformation--abi-windowed|--abi-call0 â ABI tag-march=CPU[-EXT...][+EXT...] â Target processor (z80, z180, ez80, gbz80, z80n, r800) and extensions-local-prefix=prefix â Mark labels with prefix as local-colonless â Accept colonless labels-sdcc â Accept SDCC output-fp-s=FORMAT â Single precision float format (default ieee754 32-bit)-fp-d=FORMAT â Double precision float format (default ieee754 64-bit)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. 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 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.
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.)
@file â Read command-line options from file. Options are separated by whitespace; quotes and backslash escape allowed. Recursive @file supported.-a[cdghlmns] â Turn on listings. Options: ac omit false conditionals, ad omit debugging directives, ag include general info, ah include high-level source, al include assembly, am include macro expansions, an omit forms processing, as include symbols. Use =file to set listing file name. Default: -ahls.--alternate â Begin in alternate macro mode.--compress-debug-sections â Compress DWARF debug sections using zlib with SHF_COMPRESSED (ELF ABI).--compress-debug-sections=none|zlib|zlib-gnu|zlib-gabi â Control debug section compression.--nocompress-debug-sections â Do not compress debug sections (default for most targets).-D â Ignored (script compatibility).--debug-prefix-map old=new â Remap debug information directory names.--defsym sym=value â Define a symbol before assembly. Value must be integer constant (0x hex, 0 octal).-f â "Fast" mode: skip whitespace and comment preprocessing (assume compiler output).-g, --gen-debug â Generate debugging information (STABS, ECOFF, or DWARF2).--gstabs â Generate stabs debugging information.--gstabs+ â Generate stabs with GNU extensions.--gdwarf-2, --gdwarf-3, --gdwarf-4, --gdwarf-5 â Generate DWARF2/3/4/5 debugging information.--gdwarf-sections â Create per-code-section debug line sections (e.g., .debug_line.text.func).--gdwarf-cie-version=version â DWARF CIE version (1, 3, 4; default 1).--size-check=error|warning â Issue error/warning for invalid ELF .size directive.--elf-stt-common=no|yes â Generate STT_COMMON symbols.--generate-missing-build-notes=yes|no â Generate GNU Build attribute notes if missing.--help â Print command-line options summary and exit.--target-help â Print target-specific options summary and exit.-I dir â Add directory to search list for .include directives.-J â Don't warn about signed overflow.-K â Issue warnings when difference tables altered for long displacements.-L, --keep-locals â Keep local symbols (e.g., .L for ELF).--listing-lhs-width=number â Max width of output data column (in words).--listing-lhs-width2=number â Max width for continuation lines.--listing-rhs-width=number â Max width of input source line (bytes).--listing-cont-lines=number â Max lines printed for a single input line.--multibyte-handling=allow|warn|warn-sym-only â Control handling of multibyte characters.--no-pad-sections â Stop padding output sections to alignment.-o objfile â Name the output object file.-R â Fold data section into text section.--sectname-subst â Honor substitution sequences in section names.--statistics â Print max space and total time used.--strip-local-absolute â Remove local absolute symbols from symbol table.-v, -version â Print as version.--version â Print as version and exit.-W, --no-warn â Suppress warning messages.--fatal-warnings â Treat warnings as errors.--warn â Don't suppress warnings or treat as errors.-w â Ignored.-x â Ignored.-Z â Generate object file even after errors.-- | files ... â Standard input or source files to assemble.gcc(1), ld(1), and the Info entries for binutils and ld.
Copyright (c) 1991-2022 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
binutils-2.38 2025-12-03 AS(1)
Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-16 09:26 @2600:1f28:365:80b0:7cb9:fb:26c1:e368
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)