AS(1)
โจ AS(1) โ GNU Development Tools โจ
Okay bestie, this is the manual for as, the GNU assembler ๐ It lives in the GNU Development Tools family, and it's the one that's built to be portable across a bunch of different chip architectures ๐ง
๐ธ NAME ๐ธ
AS is the portable GNU assembler, and honestly it's giving "works everywhere" energy โจ
๐ SYNOPSIS ๐
Here's the full lineup of ways you can call it. Don't panic, most of these are optional ๐
as [-a[cdghilns][=file]]
[--alternate]
[--compress-debug-sections] [--nocompress-debug-sections]
[-D]
[--dump-config]
[--debug-prefix-map old=new]
[--defsym sym=val]
[--elf-stt-common=[no|yes]]
[--emulation=name]
[-f]
[-g] [--gstabs] [--gstabs+]
[--gdwarf-<N>] [--gdwarf-sections]
[--gdwarf-cie-version=VERSION]
[--generate-missing-build-notes=[no|yes]]
[--gsframe] [--gsframe=[no|yes]]
[--hash-size=N]
[--help] [--target-help]
[--info] [--no-info]
[-I dir]
[-J]
[-K]
[--keep-locals]
[-L]
[--listing-lhs-width=NUM]
[--listing-lhs-width2=NUM]
[--listing-rhs-width=NUM]
[--listing-cont-lines=NUM]
[--multibyte-handling=[allow|warn|warn-sym-only]]
[--no-pad-sections]
[-o objfile] [-R]
[--scfi=experimental]
[--sectname-subst]
[--size-check=[error|warning]]
[--statistics]
[-v] [--verbose]
[-version] [--version]
[-W] [--no-warn] [--warn] [--fatal-warnings]
[-w] [-x]
[-Z] [@FILE]
[target-options]
[--|files ...]
๐ฆ TARGET ๐ฆ
Okay so here's the thing: every chip family has its own extra options ๐ The ones below only matter when you're targeting that specific architecture, so pick your chip and go, no cap โจ
๐ Target AArch64 options
[-EB|-EL]
[-mabi=ABI]
๐ Target Alpha options
[-mcpu]
[-mdebug | -no-mdebug]
[-replace | -noreplace]
[-relax] [-g] [-Gsize]
[-F] [-32addr]
๐ง Target ARC options
[-mcpu=cpu]
[-mA6|-mARC600|-mARC601|-mA7|-mARC700|-mEM|-mHS]
[-mcode-density]
[-mrelax]
[-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]
๐ DESCRIPTION ๐
okay so GNU as is really a whole family of assemblers ๐ if you've used the GNU assembler on one architecture, you'll feel right at home on another one โจ each version shares a ton with the others, like object file formats, most assembler directives (aka pseudo-ops) and the general assembler syntax ๐ฆ
as is mainly built to assemble the output of the GNU C compiler, gcc, so the linker, ld, can use it ๐ซถ that said, we really tried to make as assemble correctly everything that other assemblers for the same machine would assemble. any exceptions are written down explicitly, so no surprises ๐ BUT it doesn't mean as always uses the exact same syntax as another assembler for the same architecture. for example, we know of several incompatible versions of 680x0 assembly language syntax. chaotic, I know ๐
each time you run as, it assembles exactly one source program ๐ธ that program is made up of one or more files. (the standard input counts as a file too, btw ๐ง)
you give as a command line with zero or more input file names. the input files get read from left to right ๐ any command-line argument (in any position) that doesn't have a special meaning gets treated as an input file name โจ
if you don't give as any file names, it tries to read one input file from the as standard input, which is normally your terminal ๐ป you might have to type ctl-D to tell as there's no more program to assemble ๐ญ
if you need to explicitly name the standard input file on your command line, use -- ๐
if the source is empty, as produces a small, empty object file. tiny, but valid ๐ฅบ
as may write warnings and error messages to the standard error file (usually your terminal too) ๐ฅ this shouldn't happen when a compiler runs as automatically ๐
warnings tell you about an assumption as made so it could keep assembling a flawed program. errors tell you about a grave problem that stops the assembly dead ๐
if you're invoking as through the GNU C compiler, you can use the -Wa option to pass arguments through to the assembler ๐ฆ the assembler arguments have to be separated from each other (and from the -Wa) by commas, no spaces โจ 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 don't need the -Wa thing, because the compiler automatically passes lots of its own command-line options along to the assembler for you ๐ซถ if you're curious, you can call the GNU compiler driver with the -v option to see exactly what options it passes to each compilation pass, including the assembler ๐
โจ OPTIONS โจ
@fileโ okay so this one reads command-line options fromfile๐ the options it reads get slotted in right where the original@fileoption was. iffiledoesn't exist or can't be read, then the option gets treated literally and doesn't get removed ๐
options inside file are separated by whitespace ๐ซง if you need a whitespace character inside an option, wrap the whole option in single or double quotes. any character (including a backslash) can be included by putting a backslash in front of it ๐ฆ the file can even contain more @file options of its own, and those get processed recursively ๐
-a[cdghilmns]โ turns on listings, in any of a bunch of different ways ๐-acomits false conditionals-adomits debugging directives-agincludes general information, like theasversion and the options passed-ahincludes high-level source-alincludes assembly-aliincludes assembly with ginsn-amincludes macro expansions-anomits forms processing-asincludes symbols=filesets the name of the listing file
you can mix these together! for example, -aln gives you an assembly listing without forms processing ๐
the =file option, if you use it, has to be the last one ๐ and by itself, -a defaults to -ahls ๐
--alternateโ begins in alternate macro mode ๐ธ--compress-debug-sectionsโ compresses DWARF debug sections using zlib withSHF_COMPRESSEDfrom the ELF ABI ๐๏ธ heads up: the resulting object file might not be compatible with older linkers and object file utilities ๐ also, if compression would make a given section larger, it doesn't get compressed. smart ๐ง--compress-debug-sections=none,--compress-debug-sections=zlib,--compress-debug-sections=zlib-gnu,--compress-debug-sections=zlib-gabi,--compress-debug-sections=zstdโ these control how DWARF debug sections get compressed ๐--compress-debug-sections=noneis the same as--nocompress-debug-sections--compress-debug-sections=zliband--compress-debug-sections=zlib-gabiare the same as plain--compress-debug-sections--compress-debug-sections=zlib-gnucompresses DWARF debug sections using the obsoleted zlib-gnu format ๐ฅ the debug sections get renamed so they begin with.zdebug--compress-debug-sections=zstdcompresses DWARF debug sections using zstd โก
note: if compression would actually make a section larger, then it's not compressed nor renamed ๐
--nocompress-debug-sectionsโ does not compress DWARF debug sections ๐ โโ๏ธ this is usually the default for all targets except x86/x86_64, but a configure time option can be used to override that โ๏ธ-Dโ enables debugging in target specific backends, if they support it ๐ง otherwise it's ignored. even if it's ignored, this option is still accepted, for script compatibility with calls to other assemblers ๐ซถ--debug-prefix-map old=newโ when assembling files in directoryold, debugging information describing them gets recorded as if they were innewinstead ๐บ๏ธ--defsym sym=valueโ defines the symbolsymto bevaluebefore the input file gets assembled โจvaluehas to be an integer constant. just like in C, a leading0xmeans hexadecimal and a leading0means octal ๐ข you can override the symbol's value inside a source file with the.setpseudo-op ๐--dump-configโ displays how the assembler is configured, and then exits ๐งพ--elf-stt-common=no,--elf-stt-common=yesโ these control whether the ELF assembler should generate common symbols with theSTT_COMMONtype ๐ฆ the default can be controlled by the--enable-elf-stt-commonconfigure option ๐ ๏ธ--emit-local-absoluteโ emits even pre-defined (local) absolute symbols to the outgoing symbol table ๐ค heads up: this isn't the exact opposite of--strip-local-absolute, so don't treat them as mirror images ๐--emulation=nameโ if the assembler is configured to support multiple different target configurations, this option lets you pick the one you want ๐ฏ-fโ "fast"! ๐๏ธ skips whitespace and comment preprocessing, assuming the source is compiler output ๐ค-g,--gen-debugโ generates debugging information for each assembler source line, using whichever debug format the target prefers ๐ right now that means either STABS, ECOFF or DWARF2 ๐ when the format is DWARF, a.debug_infoand.debug_linesection only gets emitted when the assembly file doesn't generate one itself ๐--gstabsโ generates stabs debugging information for each assembler line ๐ this might help you debug assembler code, if your debugger can handle it ๐--gstabs+โ generates stabs debugging information for each assembler line too, but with GNU extensions that probably only gdb can handle ๐ other debuggers might crash or refuse to read your program because of them ๐ญ this might help debug assembler code. right now, the only GNU extension is the location of the current working directory at assembling time ๐--gdwarf-2โ generates DWARF2 debugging information for each assembler line ๐ฆ this might help debug assembler code, if your debugger can handle it. note: this option is only supported by some targets, not all of them ๐ฏ--gdwarf-3โ basically the same as--gdwarf-2, except it allows for the possibility of extra debug information as per version 3 of the DWARF specification ๐ heads up: turning this on doesn't guarantee any extra information gets generated. that choice is made per target ๐คทโโ๏ธ--gdwarf-4โ basically the same as--gdwarf-2, except it allows for the possibility of extra debug information as per version 4 of the DWARF specification ๐ again, turning this on doesn't guarantee any extra information, since the choice is made on a per target basis ๐--gdwarf-5โ basically the same as--gdwarf-2, except it allows for the possibility of extra debug information as per version 5 of the DWARF specification ๐ yep, same deal: no guarantees, and it depends on the target ๐--gdwarf-sectionsโ instead of creating a.debug_linesection, this creates a series of.debug_line.foosections, wherefoois the name of the matching code section ๐งฉ for example, a code section called.text.funcgets its DWARF line number information placed into a section called.debug_line.text.func. if the code section is just called.text, the debug line section still gets called just.debug_line, no suffix ๐ธ--gdwarf-cie-version=versionโ controls which version of DWARF Common Information Entries (CIEs) get produced ๐งพ if you don't specify this flag, the default is version 1, though some targets can change that default. other possible values forversionare 3 or 4 ๐ข--generate-missing-build-notes=yes,--generate-missing-build-notes=noโ these control whether the ELF assembler should generate GNU Build attribute notes when none are in the input sources ๐๏ธ the default can be controlled by the--enable-generate-build-notesconfigure option โ๏ธ--gsframe,--gsframe,--gsframe=no,--gsframe=yesโ creates a.sframesection from CFI directives ๐ช the explicit--gsframe=yesbehaves the same as--gsframe, and you can suppress generation with--gsframe=no๐ โโ๏ธ--hash-size Nโ ignored! ๐ซ it's only supported so the command line stays compatible with other assemblers ๐ซถ--helpโ prints a summary of the command-line options and then exits ๐--target-helpโ prints a summary of all the target specific options and then exits ๐ฏ--infoโ doesn't suppress informational messages ๐ข--no-infoโ suppresses informational messages ๐คซ-I dirโ adds directorydirto the search list for.includedirectives ๐-Jโ don't warn about signed overflow ๐
okay so the options list keeps going, bestie, and it's getting spicy ๐ถ๏ธโจ
-Kโ ๐จ this one warns you when difference tables get altered for long displacements. Keep an eye out for it ๐-L,--keep-localsโ keeps local symbols in the symbol table ๐๏ธ These are the ones that start with the system's local label prefix, which is usually.Lon ELF systems orLon traditional a.out systems.--listing-lhs-width=numberโ sets the max width, in words, of the output data column in an assembler listing tonumber๐--listing-lhs-width2=numberโ same vibe as above, but for the continuation lines in a listing ๐ง--listing-rhs-width=numberโ caps how wide an input source line can be when it shows up in a listing, atnumberbytes ๐--listing-cont-lines=numberโ limits how many lines get printed in a listing for one line of input. The cap isnumber+ 1 ๐ธ--multibyte-handling=allow,--multibyte-handling=warn,--multibyte-handling=warn-sym-only,--multibyte-handling=warn_sym_onlyโ decides how the assembler deals with multibyte characters in your input ๐ Default isallow, which lets them through with zero drama, and you can get that back any time by usingallow.warnmakes the assembler complain every single time it spots a multibyte character ๐ญwarn-sym-onlyis the chill version: it only warns when a symbol gets defined with a multibyte name. (Referencing an undefined symbol won't trigger a warning, fyi.) Note thatwarn_sym_onlyis also accepted, just spelled with underscores instead of dashes ๐ซถ--no-pad-sectionsโ tells the assembler to stop padding the ends of output sections out to the section's alignment. Padding is the default, but it can waste space you actually need on targets with tight memory constraints ๐ฅบ-o objfileโ names the object-file output fromasasobjfile๐-Rโ folds the data section into the text section ๐--reduce-memory-overheadsโ literally does nothing ("ignored") ๐ It's only here so tools that pass the same option to both the assembler and the linker don't get upset.--scfi=experimentalโ this one is a whole mood ๐ฎ It controls whether the assembler should synthesize CFI for hand-written input. If your input already has some synthesizable CFI directives, the assembler ignores them and emits a warning. Also,--scfi=experimentalis NOT meant for compiler-generated code, inline assembly included. It's still work in progress, and only the System V AMD64 ABI is supported right now.
Every input function in assembly has to start with the .type directive, and ideally gets closed off with a .size directive. When you use SCFI, each .type directive makes GAS start a brand new FDE (a.k.a. Function Descriptor Entry). That means each .type basically finalises whatever block of instructions came before it as its own distinct FDE ๐ง โจ
--sectname-substโ honors substitution sequences in section names ๐--size-check=error,--size-check=warningโ throws an error or a warning for an invalid ELF.sizedirective. Pick your fighter ๐ฅ--statisticsโ prints the maximum space (in bytes) and the total time (in seconds) the assembly used ๐--strip-local-absoluteโ removes local absolute symbols from the outgoing symbol table ๐งน-v,--verboseโ prints theasversion ๐ฆ--version,-versionโ prints theasversion and then exits ๐-W,--no-warnโ suppresses warning messages. Shh ๐คซ--warnโ doesn't suppress warnings, and doesn't treat them as errors either. Just vibes ๐ท--fatal-warningsโ treats warnings as errors. No second chances ๐-wโ ignored ๐-xโ also ignored ๐-Zโ generates an object file even after errors. Chaotic good energy ๐ช๏ธ-- | files ...โ the input is either standard input or source files to assemble ๐ฅ
๐ AArch64 options
These are available when as is configured for the 64-bit mode of the ARM Architecture (AArch64). ARM girlies, this is for you ๐ซถ
-EBโ marks the output as encoded for a big-endian processor ๐-ELโ marks the output as encoded for a little-endian processor ๐-mabi=abiโ tells the assembler which ABI your source code uses. The recognized arguments are"ilp32"and"lp64", which decide whether the generated object file is ELF32 or ELF64. The default is"lp64"๐ง-mcpu=processor[+extension...]โ picks the target processor. If you try to assemble an instruction that won't run on that processor, the assembler will throw an error at you ๐ซ These processor names are recognized:"cortex-a34","cortex-a35","cortex-a53","cortex-a55","cortex-a57","cortex-a65","cortex-a65ae","cortex-a72","cortex-a73","cortex-a75","cortex-a76","cortex-a76ae","cortex-a77","cortex-a78","cortex-a78ae","cortex-a78c","cortex-a510","cortex-a520","cortex-a710","cortex-a720","ares","exynos-m1","falkor","neoverse-n1","neoverse-n2","neoverse-e1","neoverse-v1","qdf24xx","saphira","thunderx","vulcan","xgene1","xgene2","cortex-r82","cortex-x1","cortex-x2","cortex-x3", and"cortex-x4". The special name"all"lets the assembler accept instructions valid for any supported processor, including every optional extension ๐คฏ
Beyond the basic instruction set, you can tell the assembler to accept, or restrict, various extension mnemonics that extend the processor โจ
If some implementations of a processor can have an extension, those extensions get switched on automatically. So you usually won't need to specify extra extensions yourself ๐
-march=architecture[+extension...]โ picks the target architecture. Same deal as-mcpu: the assembler errors out if you try to assemble something that won't execute on that architecture ๐ These architecture names are recognized:"armv8-a","armv8.1-a","armv8.2-a","armv8.3-a","armv8.4-a","armv8.5-a","armv8.6-a","armv8.7-a","armv8.8-a","armv8.9-a","armv8-r","armv9-a","armv9.1-a","armv9.2-a","armv9.3-a","armv9.4-a", and"armv9.5-a"๐ธ
If you specify both -mcpu and -march, the assembler goes with the -mcpu setting. If you specify neither, it defaults to -mcpu=all ๐ซ
The architecture option can be extended with the same instruction set extension options as -mcpu. The difference is that extensions aren't always enabled by default for -march ๐ฆ
-mverbose-errorโ turns on verbose error messages for AArch64 gas. This one is on by default ๐ฃ-mno-verbose-errorโ turns verbose error messages off for AArch64 gas ๐ค-menable-sysreg-checkingโ turns on error messages for when you try to assemble a system register access that won't execute on the target architecture ๐ง
๐ Alpha options
These are available when as is configured for an Alpha processor ๐
-mcpuโ picks the target processor. If you try to assemble an instruction that won't run on it, the assembler might either expand the instruction as a macro or throw an error. This option is equivalent to the.archdirective ๐ช These processor names are recognized:21064,"21064a",21066,21068,21164,"21164a","21164pc",21264,"21264a","21264b","ev4","ev5","lca45","ev5","ev56","pca56","ev6","ev67", and"ev68". The special name"all"lets the assembler accept instructions valid for any Alpha processor ๐
Here's the tea โ For existing practice in OSF/1 with respect to .arch, and existing practice within MILO (the Linux ARC bootloader), the numbered processor names (like 21064) enable the processor-specific PALcode instructions. The "electro-vlasic" names (like "ev4") do not ๐ค
-mdebug,-no-mdebugโ enables or disables generating.mdebugencapsulation for stabs directives and procedure descriptors. By default.mdebugswitches on automatically once the first stabs directive shows up ๐-relaxโ forces all relocations to be put into the object file, instead of saving space by resolving some of them at assembly time. Heads up: this doesn't propagate all symbol arithmetic into the object file, because not all symbol arithmetic can be represented. It can still be useful in specific applications though ๐งฉ-replace,-noreplaceโ enables or disables optimizing procedure calls, both at assemblage and at link time. These are only available for VMS targets, and-replaceis the default. See section 1.4.1 of the OpenVMS Linker Utility Manual ๐-gโ used when the compiler generates debug information. When gcc is using mips-tfile to generate debug information for ECOFF, local labels have to get passed through to the object file. Otherwise this option does nothing ๐คทโโ๏ธ-Gsizeโ a local common symbol bigger thansizegets placed in".bss", while smaller ones go into".sbss"๐งธ-F,-32addrโ ignored, kept around for backward compatibility ๐ฐ๏ธ
๐ฟ ARC options
These are available when as is configured for an ARC processor ๐
-mcpu=cpuโ selects the core processor variant ๐งฌ-EB|-ELโ picks big-endian (-EB) or little-endian (-EL) output ๐-mcode-densityโ enables the Code Density extension instructions ๐ฌ
๐ค ARM options
These are available when as is configured for the ARM processor family ๐
-mcpu=processor[+extension...]โ specifies which ARM processor variant is the target ๐ฏ-march=architecture[+extension...]โ specifies which ARM architecture variant the target uses ๐๏ธ-mfpu=floating-point-formatโ selects which Floating Point architecture is the target ๐ข-mfloat-abi=abiโ selects which floating point ABI is in use ๐งฎ-mthumbโ enables Thumb-only instruction decoding ๐-mapcs-32|-mapcs-26|-mapcs-float|-mapcs-reentrantโ selects which procedure calling convention is in use ๐-EB|-ELโ picks big-endian (-EB) or little-endian (-EL) output ๐-mthumb-interworkโ says the code was generated with interworking between Thumb and ARM code in mind ๐ค-mccsโ turns on CodeComposer Studio assembly syntax compatibility mode ๐๏ธ-kโ specifies that PIC code has been generated ๐งฉ
The following options are available when as is configured for the Blackfin processor family, so if you're working on Blackfin stuff, these are your besties ๐
-mcpu=processor[-sirevision]โ okay so this picks the target processor ๐ฏ The optionalsirevisionpart does nothing in the assembler ๐ It's just there so GCC can pass its-mcpu=option straight down without any drama. If you try to assemble an instruction that won't run on your target processor, the assembler will throw an error at you ๐ These are the processor names it recognises:bf504,bf506,bf512,bf514,bf516,bf518,bf522,bf523,bf524,bf525,bf526,bf527,bf531,bf532,bf533,bf534,bf535(not implemented yet),bf536,bf537,bf538,bf539,bf542,bf542m,bf544,bf544m,bf547,bf547m,bf548,bf548m,bf549,bf549m,bf561, andbf592โจ-mfdpicโ assemble for the FDPIC ABI ๐ฆ-mno-fdpic,-mnopicโ turns-mfdpicoff again ๐ โโ๏ธ
The following options are available when as is configured for the Linux kernel BPF processor family.
@chapter BPF Dependent Features
โจ BPF Options โจ
-EBโ big-endian eBPF output, bestie ๐-ELโ little-endian eBPF output ๐-mdialect=dialectโ picks the assembly language dialect the assembler recognises while it's working ๐ง It supportsnormalandpseudoc๐ซถ-misa-spec=specโ sets the version of the BPF instruction set to use when assembling ๐ฅ The BPF ISA versions it supports arev1v2,v3andv4๐
The value xbpf can be specified to recognise extra instructions that GCC uses for testing purposes. But beware, this is not valid BPF ๐
-mno-relaxโ tells the assembler to not relax instructions ๐ธ
Note that if no endianness option is specified on the command line, the host endianness gets used ๐ See the info pages for documentation of the CRIS-specific options ๐
The following options are available when as is configured for the C-SKY processor family.
-march=archnameโ assemble for architecturearchname๐ The--helpoption lists valid values forarchname๐-mcpu=cpunameโ assemble for architecturecpuname๐ The--helpoption lists valid values forcpunameโจ-EL,-mlittle-endianโ generates little-endian output ๐-EB,-mbig-endianโ generates big-endian output ๐-fpic,-picโ generates position-independent code ๐ฆ-mljump,-mno-ljumpโ enables or disables turning the short branch instructionsjbf,jbt, andjbrintojmpi๐ฅ This option is for V2 processors only. It gets ignored on CK801 and CK802 targets, since those don't support thejmpiinstruction, and it's enabled by default for other processors ๐-mbranch-stub,-mno-branch-stubโ passesR_CKCORE_PCREL_IMM26BY2relocations forbsrinstructions through to the linker ๐ง
This option is only available for bare-metal C-SKY V2 ELF targets, where it's enabled by default. It cannot be used in code that will be dynamically linked against shared libraries ๐ญ
-force2bsr,-mforce2bsr,-no-force2bsr,-mno-force2bsrโ enables or disables turningjbsrinstructions intobsr๐ This option is always enabled (and-mno-force2bsrgets ignored) for CK801/CK802 targets. It's also always enabled when-mbranch-stubis in effect ๐-jsri2bsr,-mjsri2bsr,-no-jsri2bsr,-mno-jsri2bsrโ enables or disables turningjsriinstructions intobsrโจ This one's enabled by default ๐-mnolrw,-mno-lrwโ enables or disables turninglrwinstructions into amovih/oripair ๐ฆ-melrw,-mno-elrwโ enables or disables extendedlrwinstructions ๐ This option is enabled by default for CK800-series processors ๐-mlaf,-mliterals-after-func,-mno-laf,-mno-literals-after-funcโ enables or disables placing literal pools after each function ๐-mlabr,-mliterals-after-br,-mno-labr,-mnoliterals-after-brโ enables or disables placing literal pools after unconditional branches ๐ธ This option is enabled by default ๐-mistack,-mno-istackโ enables or disables interrupt stack instructions โญ This option is enabled by default on CK801, CK802, and CK802 processors ๐ซถ
The following options explicitly enable certain optional instructions. Heads up: these features also get switched on automatically when you use -mcpu= to specify a processor that supports them ๐ซถ
-mhard-floatโ enables hard float instructions ๐ฅ-mmpโ enables multiprocessor instructions ๐-mcpโ enables coprocessor instructions ๐-mcacheโ enables the cache prefetch instruction ๐ง-msecurityโ enables C-SKY security instructions ๐-mtrustโ enables C-SKY trust instructions ๐-mdspโ enables DSP instructions โจ-medspโ enables enhanced DSP instructions ๐-mvdspโ enables vector DSP instructions ๐ฆ
The following options are available when as is configured for an Epiphany processor.
-mepiphanyโ the both 32 and 16 bit instructions are allowed here ๐ This is the default behaviour ๐ซถ-mepiphany16โ restricts the permitted instructions to just the 16 bit set ๐
The following options are available when as is configured for an H8/300 processor. @chapter H8/300 Dependent Features
โจ Options โจ
The Renesas H8/300 version of as has one machine-dependent option ๐
-h-tick-hexโ supportsH'00style hex constants alongside0x00style ๐-mach=nameโ sets the H8300 machine variant ๐ The following machine names are recognised:h8300h,h8300hn,h8300s,h8300sn,h8300sxandh8300sxnโจ
The following options are available when as is configured for an i386 processor.
--32 | --x32 | --64โ selects the word size, either 32 bits or 64 bits ๐--32implies the Intel i386 architecture, while--x32and--64imply the AMD x86-64 architecture with 32-bit or 64-bit word size respectively ๐ฆ
These options are only available with the ELF object file format, and they need the necessary BFD support to be included. On a 32-bit platform, you have to add --enable-64-bit-bfd to configure to enable 64-bit usage, and use x86-64 as the target platform ๐ค
-nโ by default, x86 GAS swaps out multiple nop instructions used for alignment within code sections for multi-byte nop instructions, likeleal 0(%esi,1),%esi๐ธ This switch disables that optimisation if a single byte nop (0x90) is explicitly specified as the fill byte for alignment ๐ โโ๏ธ--divideโ on SVR4-derived platforms, the character/is treated as a comment character, so it can't be used in expressions ๐ญ The--divideoption turns/into a normal character ๐ It doesn't disable/at the beginning of a line starting a comment, and it doesn't affect using#for starting a comment ๐-march=CPU[+EXTENSION...]โ this picks the target processor ๐ฏ The assembler will throw an error if you try to assemble an instruction that won't run on the target processor ๐ These processor names are recognised:i8086,i186,i286,i386,i486,i586,i686,pentium,pentiumpro,pentiumii,pentiumiii,pentium4,prescott,nocona,core,core2,corei7,iamcu,k6,k6_2,athlon,opteron,k8,amdfam10,bdver1,bdver2,bdver3,bdver4,znver1,znver2,znver3,znver4,znver5,btver1,btver2,generic32andgeneric64โจ
Besides the basic instruction set, the assembler can be told to accept extra extension mnemonics ๐ง For example, -march=i686+sse4+vmx extends i686 with sse4 and vmx ๐ฅ These extensions are currently supported: 8087, 287, 387, 687, cmov, fxsr, mmx, sse, sse2, sse3, sse4a, ssse3, sse4.1, sse4.2, sse4, avx, avx2, lahf_sahf, monitor, adx, rdseed, prfchw, smap, mpx, sha, rdpid, ptwrite, cet, gfni, vaes, vpclmulqdq, prefetchwt1, clflushopt, se1, clwb, movdiri, movdir64b, enqcmd, serialize, tsxldtrk, kl, widekl, hreset, avx512f, avx512cd, avx512er, avx512pf, avx512vl, avx512bw, avx512dq, avx512ifma, avx512vbmi, avx512_4fmaps, avx512_4vnniw, avx512_vpopcntdq, avx512_vbmi2, avx512_vnni, avx512_bitalg, avx512_vp2intersect, tdx, avx512_bf16, avx_vnni, avx512_fp16, prefetchi, avx_ifma, avx_vnni_int8, cmpccxadd, wrmsrns, msrlist, avx_ne_convert, rao_int, fred, lkgs, avx_vnni_int16, sha512, sm3, sm4, pbndkb, avx10.1, avx10.1/512, avx10.1/256, avx10.1/128, user_msr, msr_imm, apx_f, avx10.2, avx10.2/512, avx10.2/256, avx10.2/128, movrs, amx_int8, amx_bf16, amx_fp16, amx_complex, amx_transpose, amx_tf32, amx_fp8 amx_movrs, amx_avx512, amx_tile, vmx, vmfunc, smx, xsave, xsaveopt, xsavec, xsaves, aes, pclmul, fsgsbase, rdrnd, f16c, bmi2, fma, movbe, ept, lzcnt, popcnt, hle, rtm, tsx, invpcid, clflush, mwaitx, clzero, wbnoinvd, pconfig, waitpkg, uintr, cldemote, rdpru, mcommit, sev_es, lwp, fma4, xop, cx16, syscall, rdtscp, 3dnow, 3dnowa, sse4a, sse5, snp, invlpgb, tlbsync, rmpquery, rmpread, svme, gmism2, gmiccs, padlockrng2, padlockphe2, padlockxmodx and padlock ๐ Note that these extension mnemonics can be prefixed with no to revoke the respective (and any dependent) functionality ๐
Also, the suffixes permitted on -march=avx10.<N> enforce a vector length restriction. So even though these are otherwise "enabling" options, using these suffixes will disable all insns with wider vector or mask register operands ๐
When the .arch directive is used with -march, the .arch directive will take precedent ๐
-mtune=CPUโ this option picks a processor to optimise for ๐ฏ When it's used together with the-marchoption, only instructions of the processor specified by the-marchoption will be generated ๐
Valid CPU values are identical to the processor list of -march=CPU ๐ซถ
These flags are where the assembler gets picky about instruction operands, SSE, AVX, and encoding details, so pay attention bestie ๐ฆ
-moperand-check=none,-moperand-check=warning,-moperand-check=errorโ These decide whether the assembler bothers checking certain instruction operands or operand combos ๐ The classic example is an instruction where the operand size can't be figured out from the operands, and you didn't spell it out with an instruction suffix.noneskips the checks entirely.warning(the default โจ) throws a warning when a check fails.errormakes a failed check a full-on error ๐ โโ๏ธ-msse2avxโ Tells the assembler to encode SSE instructions with a VEX prefix, which means AVX has to be available ๐ SSE instructions that use extended GPRs get encoded with an EVEX prefix instead, and that one needs AVX512 or AVX10 to be available ๐-muse-unaligned-vector-moveโ Makes the assembler encode aligned vector moves as unaligned vector moves ๐ซถ-msse-check=none,-msse-check=warning,-msse-check=errorโ These control whether the assembler checks SSE instructions at all ๐noneis the default, so no checking happens unless you ask for it.warninggives you a warning for any SSE instruction, anderrorgives you an error for any SSE instruction ๐-mavxscalar=128,-mavxscalar=256โ Decides how scalar AVX instructions get encoded ๐128(the default) encodes them with a 128-bit vector length, and256uses a 256-bit vector length ๐ธ
WARNING: Don't use this for production code ๐จ Because of CPU errata, the resulting code may not work on certain models. Not the vibe for real projects, bestie ๐ญ
-mvexwig=0,-mvexwig=1โ Controls how the assembler encodes VEX.W-ignored (WIG) VEX instructions ๐ฆ0(the default) encodes them withvex.w = 0.1encodes WIG EVEX instructions withvex.w = 1๐ง
WARNING: Don't use this for production code ๐จ Due to CPU errata, the resulting code may not work on certain models. Seriously, keep this one out of your real stuff ๐
-mevexlig=128,-mevexlig=256,-mevexlig=512โ Picks the vector length for length-ignored (LIG) EVEX instructions ๐128is the default โจ256and512encode them with a 256-bit or 512-bit vector length, respectively ๐-mevexwig=0,-mevexwig=1โ Controls how the assembler encodes w-ignored (WIG) EVEX instructions ๐0(the default) encodes them withevex.w = 0, and1encodes them withevex.w = 1๐ซถ-mmnemonic=att,-mmnemonic=intelโ Picks the instruction mnemonic used for matching instructions ๐ฅ Heads up: the.att_mnemonicand.intel_mnemonicdirectives take priority over this flag ๐-msyntax=att,-msyntax=intelโ Picks the instruction syntax used when processing instructions ๐ The.att_syntaxand.intel_syntaxdirectives win over this one, so keep that in mind ๐-mnaked-regโ Lets you skip the%prefix on registers ๐ธ Same deal as before: the.att_syntaxand.intel_syntaxdirectives take precedence over it โจ-madd-bnd-prefixโ Forces the assembler to slap a BND prefix on every branch ๐ Even if you never wrote one in your source code, it's getting added anyway ๐ง-mno-sharedโ Okay, this one's a little spicy ๐ถ๏ธ On ELF targets, the assembler normally optimizes away non-PLT relocations against defined non-weak global branch targets that have default visibility.-msharedtells the assembler to generate code that could end up in a shared library, where those non-weak global branch targets with default visibility can be preempted ๐ฆ The downside is that the resulting code is slightly bigger. And this option only affects branch instructions, nothing else ๐-mbig-objโ On PE/COFF targets, this forces the big object file format ๐ That format lets you have more than 32768 sections, so it's giving "I need a lot of sections" energy ๐ฆ-momit-lock-prefix=no,-momit-lock-prefix=yesโ These control how the assembler encodes the lock prefix ๐ It's really a workaround for processors that choke on the lock prefix ๐yesomits all lock prefixes, andnoencodes the lock prefix as usual (the default โจ)
WARNING: This option can only be safely used with single-core, single-thread computers ๐จ Don't try it on anything fancier, bestie ๐ญ
-mfence-as-lock-add=no,-mfence-as-lock-add=yesโ These control howlfence,mfenceandsfenceget encoded ๐yesencodes all three aslock addl $0x0, (%rsp)in 64-bit mode and aslock addl $0x0, (%esp)in 32-bit mode ๐งnoencodes them as usual, which is the default ๐-mrelax-relocations=no,-mrelax-relocations=yesโ Controls whether the assembler generates relax relocations โจ In 32-bit mode that meansR_386_GOT32X, and in 64-bit mode it meansR_X86_64_GOTPCRELXandR_X86_64_REX_GOTPCRELX๐yesgenerates relax relocations, andnodoesn't ๐ซถ The default can be changed with the configure option--enable-x86-relax-relocations๐ฅ-mtls-check=no,-mtls-check=yesโ Controls whether the assembler checks TLS relocations ๐yeschecks them,noskips the check ๐ โโ๏ธ The default can be set with the configure option--enable-x86-tls-check๐-malign-branch-boundary=NUMโ Decides how the assembler aligns branches that have segment prefixes or NOPs ๐ฆNUMhas to be a power of 2, and it should be0or at least16๐ Branches get aligned within aNUMbyte boundary ๐ธ The default is-malign-branch-boundary=0, which means branches don't get aligned at all ๐-malign-branch=TYPE[+TYPE...]โ Picks which types of branches get aligned ๐งTYPEcan be a combo ofjcc(conditional jumps),fused(fused conditional jumps),jmp(unconditional jumps),call(calls),ret(rets), andindirect(indirect jumps and calls) ๐ The default is-malign-branch=jcc+fused+jmpโจ-malign-branch-prefix-size=NUMโ Sets the maximum number of prefixes an instruction can have and still get its branch aligned ๐NUMshould be between0and5, and the defaultNUMis5๐-mbranches-within-32B-boundariesโ This one's a whole package deal ๐ฆ It aligns conditional jumps, fused conditional jumps and unconditional jumps within a 32 byte boundary, with up to 5 segment prefixes on an instruction ๐ It's equivalent to-malign-branch-boundary=32 -malign-branch=jcc+fused+jmp -malign-branch-prefix-size=5, so you can skip typing all that out ๐ซถ The default doesn't align branches ๐-mlfence-after-load=no,-mlfence-after-load=yesโ Controls whether the assembler generateslfenceafter load instructions ๐ฅyesgenerates it, andnodoesn't, which is the default ๐-mlfence-before-indirect-branch=none,-mlfence-before-indirect-branch=all,-mlfence-before-indirect-branch=register,-mlfence-before-indirect-branch=memoryโ Controls whether the assembler generateslfencebefore indirect near branch instructions ๐ก๏ธallgenerateslfencebefore an indirect near branch via register and issues a warning before an indirect near branch via memory ๐ It also implicitly sets-mlfence-before-ret=shlwhen there's no explicit-mlfence-before-ret=๐registergenerateslfencebefore an indirect near branch via register ๐ซถmemoryissues a warning before an indirect near branch via memory ๐nonedoesn't generatelfenceor issue any warning, and it's the default โจ
Heads up:lfencewon't be generated before an indirect near branch via register when you use-mlfence-after-load=yes, since thelfencegets generated after the branch target register is loaded ๐ง
-mlfence-before-ret=none,-mlfence-before-ret=shl,-mlfence-before-ret=or,-mlfence-before-ret=yes,-mlfence-before-ret=notโ Controls whether the assembler generateslfencebeforeret๐orgenerates anorinstruction withlfence๐ธshlandyesboth generate ashlinstruction withlfence๐notgenerates anotinstruction withlfence๐nonedoesn't generatelfence, and it's the default ๐ฆ-mx86-used-note=no,-mx86-used-note=yesโ Controls whether the assembler generates theGNU_PROPERTY_X86_ISA_1_USEDandGNU_PROPERTY_X86_FEATURE_2_USEDGNU property notes ๐ง The default can be controlled with the--enable-x86-used-noteconfigure option โจ-mevexrcig=rne,-mevexrcig=rd,-mevexrcig=ru,-mevexrcig=rzโ These decide how SAE-only EVEX instructions get encoded ๐rneencodes the RC bits of the EVEX instruction as00, and it's the default โจrd,ruandrzencode the SAE-only EVEX instructions with01,10and11RC bits, respectively ๐-mamd64,-mintel64โ Tells the assembler to accept only the AMD64 or Intel64 ISA in 64-bit mode ๐ By default, it accepts the common ISA, plus the Intel64 only and AMD64 ISAs ๐ซถ-O0 | -O | -O1 | -O2 | -Osโ Optimizes instruction encoding for smaller instruction size ๐-Oand-O1do a bunch of cute stuff: they encode 64-bit register load instructions with a 64-bit immediate as 32-bit register load instructions with 31-bit or 32-bit immediates ๐ They encode 64-bit register clearing instructions as 32-bit register clearing instructions ๐ธ They encode 256-bit/512-bit VEX/EVEX vector register clearing instructions as 128-bit VEX vector register clearing instructions ๐ฆ They encode 128-bit/256-bit EVEX vector register load/store instructions as VEX vector register load/store instructions ๐ง And they encode 128-bit/256-bit EVEX packed integer logical instructions as 128-bit/256-bit VEX packed integer logical instructions ๐
-O2 is where things get spicy ๐ฅ It includes everything from -O1 and also encodes 256-bit/512-bit EVEX vector register clearing instructions, plus 128-bit EVEX vector register clearing instructions. In 64-bit mode, VEX encoded instructions with commutative source operands also get their source operands swapped, but only if that lets them use the 2-byte VEX prefix form instead of the 3-byte one ๐ง Certain forms of AND, plus OR with the same (register) operand specified twice, also get switched over to TEST โจ
-Osโ bestie, this one includes -O2 optimization and also encodes 16-bit, 32-bit and 64-bit register tests with an immediate as an 8-bit register test with an immediate ๐-O0turns this optimization off ๐
๐ฆ Ubicom IP2K series
These options show up when as is configured for the Ubicom IP2K series ๐ธ
-mip2022extโ specifies that the extended IP2022 instructions are allowed โจ-mip2022โ restores the default behaviour, which limits the permitted instructions to just the basic IP2022 ones ๐
๐ Renesas M32C and M16C processors
These options show up when as is configured for the Renesas M32C and M16C processors ๐
-m32cโ assemble M32C instructions ๐-m16cโ assemble M16C instructions (this is the default) ๐-relaxโ enables support for link-time relaxations ๐-h-tick-hexโ supportsH'00style hex constants in addition to0x00style ๐ซถ
๐ธ Renesas M32R (formerly Mitsubishi M32R) series
These options show up when as is configured for the Renesas M32R (formerly Mitsubishi M32R) series ๐ฆ
--m32rxโ specifies which processor in the M32R family is the target ๐ฅ The default is normally the M32R, but this option switches it to the M32RX โจ--warn-explicit-parallel-conflictsor--Wpโ produces warning messages whenever questionable parallel constructs show up ๐--no-warn-explicit-parallel-conflictsor--Wnpโ does not produce warning messages when questionable parallel constructs show up ๐ โโ๏ธ
๐ Motorola 68000 series
These options show up when as is configured for the Motorola 68000 series ๐ง
-lโ shortens references to undefined symbols to one word instead of two ๐ซ-m68000|-m68008|-m68010|-m68020|-m68030|-m68040|-m68060|-m68302|-m68331|-m68332|-m68333|-m68340|-mcpu32|-m5200โ specifies which processor in the 68000 family is the target ๐ The default is normally the 68020, but this can be changed at configuration time โญ-m68881|-m68882|-mno-68881|-mno-68882โ tells it whether the target machine does (or does not) have a floating-point coprocessor ๐ The default is to assume a coprocessor for the 68020, 68030, and cpu32 ๐ The basic 68000 isn't compatible with the 68881, but you can specify a combo of the two, since it's possible to emulate the coprocessor instructions with the main processor ๐ค-m68851|-mno-68851โ tells it whether the target machine does (or does not) have a memory-management unit coprocessor ๐ The default is to assume an MMU for the 68020 and up โจ
For details about the PDP-11 machine dependent features options, see PDP-11-Options ๐
-mpic|-mno-picโ generates position-independent (or position-dependent) code ๐ฆ The default is-mpic๐-mallor-mall-extensionsโ enables all instruction set extensions. This is the default ๐ฅ-mno-extensionsโ disables all instruction set extensions ๐ โโ๏ธ-mextension|-mno-extensionโ enables (or disables) one particular instruction set extension ๐ซถ-mcpuโ enables the instruction set extensions supported by a particular CPU, and disables all other extensions ๐-mmachineโ enables the instruction set extensions supported by a particular machine model, and disables all other extensions ๐
๐ง picoJava processor
These options show up when as is configured for a picoJava processor ๐ธ
-mbโ generates "big endian" format output ๐-mlโ generates "little endian" format output ๐
๐ PRU processor
These options show up when as is configured for a PRU processor โจ
-mlink-relaxโ assumes that LD would optimize LDI32 instructions by checking the upper 16 bits of the expression ๐ง If they are all zeros, LD would shorten the LDI32 instruction to a single LDI ๐ In that case, "as" will output DIFF relocations for diff expressions ๐ซถ-mno-link-relaxโ assumes that LD would not optimize LDI32 instructions ๐ As a consequence, DIFF relocations will not be emitted ๐-mno-warn-regname-labelโ does not warn if a label name matches a register name ๐ Assembler programmers usually want this warning to be emitted, but C compilers may want to turn it off ๐
๐ฆ MIPS processor
These options show up when as is configured for a MIPS processor ๐
-G numโ sets the largest size of an object that can be referenced implicitly with the "gp" register ๐ฅ It's only accepted for targets that use ECOFF format, such as a DECstation running Ultrix ๐ฅ๏ธ The default value is 8 โจ-EBโ generates "big endian" format output ๐-ELโ generates "little endian" format output ๐-mips1|-mips2|-mips3|-mips4|-mips5|-mips32|-mips32r2|-mips32r3|-mips32r5|-mips32r6|-mips64|-mips64r2|-mips64r3|-mips64r5|-mips64r6โ generates code for a particular MIPS Instruction Set Architecture level ๐-mips1is an alias for-march=r3000,-mips2is an alias for-march=r6000,-mips3is an alias for-march=r4000, and-mips4is an alias for-march=r8000๐ซ-mips5,-mips32,-mips32r2,-mips32r3,-mips32r5,-mips32r6,-mips64,-mips64r2,-mips64r3,-mips64r5, and-mips64r6correspond to generic MIPS V, MIPS32, MIPS32 Release 2, MIPS32 Release 3, MIPS32 Release 5, MIPS32 Release 6, MIPS64, MIPS64 Release 2, MIPS64 Release 3, MIPS64 Release 5, and MIPS64 Release 6 ISA processors, respectively ๐คฏ-march=cpuโ generates code for a particular MIPS CPU ๐-mtune=cpuโ schedules and tunes for a particular MIPS CPU ๐ง-mfix7000|-mno-fix7000โ causes nops to be inserted if the read of the destination register of an mfhi or mflo instruction occurs in the following two instructions ๐-mfix-rm7000|-mno-fix-rm7000โ causes nops to be inserted if a dmult or dmultu instruction is followed by a load instruction ๐ซ-mfix-r5900|-mno-fix-r5900โ does not try to schedule the preceding instruction into the delay slot of a branch placed at the end of a short loop of six instructions or fewer. It always schedules a "nop" instruction there instead ๐ The short loop bug can, under certain conditions, make loops run only once or twice, thanks to a hardware bug in the R5900 chip ๐ญ
โ ๏ธ The short loop bug is a real hardware issue on the R5900 chip, so keep -mfix-r5900 in mind if your loops are acting weird ๐
-mdebug|-no-mdebugโ causes stabs-style debugging output to go into an ECOFF-style.mdebugsection instead of the standard ELF.stabssections ๐ง-mpdr|-mno-pdrโ controls generation of ".pdr" sections ๐-mgp32|-mfp32โ register sizes are normally inferred from the ISA and ABI, but these flags force a certain group of registers to be treated as 32 bits wide at all times ๐-mgp32controls the size of general-purpose registers, and-mfp32controls the size of floating-point registers ๐-mgp64|-mfp64โ register sizes are normally inferred from the ISA and ABI, but these flags force a certain group of registers to be treated as 64 bits wide at all times ๐-mgp64controls the size of general-purpose registers, and-mfp64controls the size of floating-point registers ๐-mfpxxโ register sizes are normally inferred from the ISA and ABI, but using this flag in combination with-mabi=32enables an ABI variant that operates correctly with floating-point registers that are 32 or 64 bits wide ๐ฆ-modd-spreg|-mno-odd-spregโ enables use of floating-point operations on odd-numbered single-precision registers when the ISA supports it ๐ฅ-mfpxximplies-mno-odd-spreg, otherwise the default is-modd-spregโจ-mips16|-no-mips16โ generates code for the MIPS 16 processor ๐ This is equivalent to putting ".module mips16" at the start of the assembly file ๐-no-mips16turns this option off ๐ โโ๏ธ-mmips16e2|-mno-mips16e2โ enables the use of MIPS16e2 instructions in MIPS16 mode ๐ซ This is equivalent to putting ".module mips16e2" at the start of the assembly file ๐-mno-mips16e2turns this option off ๐ โโ๏ธ-mmicromips|-mno-micromipsโ generates code for the microMIPS processor ๐ธ This is equivalent to putting ".module micromips" at the start of the assembly file ๐-mno-micromipsturns this option off ๐ โโ๏ธ This is equivalent to putting ".module nomicromips" at the start of the assembly file ๐ค-msmartmips|-mno-smartmipsโ enables the SmartMIPS extension to the MIPS32 instruction set ๐ This is equivalent to putting ".module smartmips" at the start of the assembly file ๐-mno-smartmipsturns this option off ๐ โโ๏ธ-mips3d|-no-mips3dโ generates code for the MIPS-3D Application Specific Extension ๐ง This tells the assembler to accept MIPS-3D instructions ๐ซถ-no-mips3dturns this option off ๐ โโ๏ธ-mdmx|-no-mdmxโ generates code for the MDMX Application Specific Extension ๐ This tells the assembler to accept MDMX instructions ๐ซถ-no-mdmxturns this option off ๐ โโ๏ธ-mdsp|-mno-dspโ generates code for the DSP Release 1 Application Specific Extension ๐ This tells the assembler to accept DSP Release 1 instructions ๐ซถ-mno-dspturns this option off ๐ โโ๏ธ-mdspr2|-mno-dspr2โ generates code for the DSP Release 2 Application Specific Extension โจ This option implies-mdsp, and it tells the assembler to accept DSP Release 2 instructions ๐ซถ-mno-dspr2turns this option off ๐ โโ๏ธ-mdspr3|-mno-dspr3โ generates code for the DSP Release 3 Application Specific Extension ๐ฅ This option implies-mdspand-mdspr2, and it tells the assembler to accept DSP Release 3 instructions ๐ซถ-mno-dspr3turns this option off ๐ โโ๏ธ-mmsa|-mno-msaโ generates code for the MIPS SIMD Architecture Extension ๐ฆ This tells the assembler to accept MSA instructions ๐ซถ-mno-msaturns this option off ๐ โโ๏ธ-mxpa|-mno-xpaโ generates code for the MIPS eXtended Physical Address (XPA) Extension ๐ธ This tells the assembler to accept XPA instructions ๐ซถ-mno-xpaturns this option off ๐ โโ๏ธ-mmt|-mno-mtโ generates code for the MT Application Specific Extension ๐ This tells the assembler to accept MT instructions ๐ซถ-mno-mtturns this option off ๐ โโ๏ธ-mmcu,-mno-mcuโ okay so this one turns on the MCU Application Specific Extension ๐. It tells the assembler to accept MCU instructions, and-mno-mcuturns it back off ๐ โโ๏ธ-mcrc,-mno-crcโ this generates code for the MIPS cyclic redundancy check (CRC) Application Specific Extension โจ. It tells the assembler to accept CRC instructions, and-mno-crcswitches it off ๐ฆ-mginv,-mno-ginvโ this one is for the Global INValidate (GINV) Application Specific Extension ๐ง. It tells the assembler to accept GINV instructions, and-mno-ginvturns it off ๐-mloongson-mmi,-mno-loongson-mmiโ this is the Loongson MultiMedia extensions Instructions (MMI) Application Specific Extension ๐. It tells the assembler to accept MMI instructions, and-mno-loongson-mmiturns it off ๐ธ-mloongson-cam,-mno-loongson-camโ generates code for the Loongson Content Address Memory (CAM) instructions ๐. It tells the assembler to accept Loongson CAM instructions, and-mno-loongson-camturns this option off ๐ซถ-mloongson-ext,-mno-loongson-extโ this one covers the Loongson EXTensions (EXT) instructions โญ. It tells the assembler to accept Loongson EXT instructions, and-mno-loongson-extturns it off ๐ฅ-mloongson-ext2,-mno-loongson-ext2โ this is the Loongson EXTensions R2 (EXT2) instructions ๐. This option implies-mloongson-ext. It tells the assembler to accept Loongson EXT2 instructions, and-mno-loongson-ext2turns this option off ๐-minsn32,-mno-insn32โ okay this one is giving strict ๐. Only 32-bit instruction encodings get used when generating code for the microMIPS processor, so no 16-bit instructions at all. It's equivalent to putting.set insn32at the start of the assembly file.-mno-insn32turns it off, and that's equivalent to putting.set noinsn32at the start of the assembly file. By default-mno-insn32is selected, so every instruction is fair game ๐--construct-floats,--no-construct-floatsโ--no-construct-floatsdisables building double width floating point constants by loading the two halves of the value into the two single width floating point registers that make up the double width register ๐ง. By default--construct-floatsis selected, so those floating point constants can be constructed โจ--relax-branch,--no-relax-branchโ--relax-branchturns on relaxation of out-of-range branches ๐ฆ. By default--no-relax-branchis selected, which means any out-of-range branches produce an error ๐-mignore-branch-isa,-mno-ignore-branch-isaโ ignores branch checks for invalid transitions between ISA modes ๐. The semantics of branches doesn't provide for an ISA mode switch, so in most cases the ISA mode a branch was encoded for has to match the ISA mode of the branch's target label. That's why GAS has checks that verify in branch assembly that the two ISA modes match.-mignore-branch-isadisables these checks. By default-mno-ignore-branch-isais selected, so any invalid branch that needs a transition between ISA modes produces an error ๐ซ-mnan=encodingโ pick between the IEEE 754-2008 (-mnan=2008) or the legacy (-mnan=legacy) NaN encoding format ๐ง . The latter is the default ๐--emulation=nameโ this one used to switch between ELF and ECOFF output on targets like IRIX 5 that supported both ๐ฐ๏ธ. MIPS ECOFF support was removed in GAS 2.24, so the option now serves little purpose. It's kept around for backwards compatibility ๐ซ
The available configuration names are: mipself, mipslelf and mipsbelf. Choosing mipself has no effect now, since the output is always ELF. mipslelf and mipsbelf select little- and big-endian output respectively, but -EL and -EB are the preferred options instead ๐
-nocppโasignores this one ๐. It's only accepted for compatibility with the native tools ๐ง--trap,--no-trap,--break,--no-breakโ these control how to deal with multiplication overflow and division by zero ๐ฅ.--trapor--no-break(which are synonyms) take a trap exception, and they only work for Instruction Set Architecture level 2 and higher.--breakor--no-trap(also synonyms, and the default) take a break exception ๐-nโ when you use this,aswill issue a warning every time it generates a nop instruction from a macro โ ๏ธ
The following options are available when as is configured for a LoongArch processor. ๐ธ
-fpic,-fPICโ generates position-independent code ๐ฆ-fno-picโ doesn't generate position-independent code (this is the default) ๐ โโ๏ธ
The following options are available when as is configured for a Meta processor. ๐ง
-mcpu=metac11โ generates code for Meta 1.1 โจ-mcpu=metac12โ generates code for Meta 1.2 ๐-mcpu=metac21โ generates code for Meta 2.1 ๐-mfpu=metac21โ lets code use the FPU hardware of Meta 2.1 ๐ฅ
See the info pages for documentation of the MMIX-specific options. ๐
The following options are available when as is configured for a NDS32 processor. ๐
-O1โ optimizes for performance ๐๏ธ-Osโ optimizes for space ๐ฆ-ELโ produces little endian data output ๐ซ-EBโ produces little endian data output (yes, the original page says little endian for this one too, so I'm keeping it exactly like that ๐)-mpicโ generates PIC ๐ซถ-mno-fp-as-gp-relaxโ suppresses fp-as-gp relaxation for this file ๐ซ-mb2bb-relaxโ back-to-back branch optimization ๐-mno-all-relaxโ suppresses all relaxation for this file ๐ โโ๏ธ-march=<arch name>โ assembles for the architecture arch name, which could bev3,v3j,v3m,v3f,v3s,v2,v2j,v2f, orv2s๐๏ธ-mbaseline=<baseline>โ assembles for the baseline baseline, which could bev2,v3, orv3m๐งฑ-mfpu-freg=FREGโ specifies an FPU configuration ๐๏ธ0โ 8 SP / 4 DP registers1โ 16 SP / 8 DP registers2โ 32 SP / 16 DP registers3โ 32 SP / 32 DP registers
-mabi=abiโ specifies an ABI version, where abi could bev1,v2,v2fp, orv2fpp๐-m[no-]macโ enables or disables multiply instructions support ๐ข-m[no-]divโ enables or disables divide instructions support โ-m[no-]16bit-extโ enables or disables 16-bit extension ๐งฉ-m[no-]dx-regsโ enables or disables thed0/d1registers ๐๏ธ-m[no-]perf-extโ enables or disables the Performance extension ๐โโ๏ธ-m[no-]perf2-extโ enables or disables the Performance extension 2 ๐โโ๏ธ๐โโ๏ธ-m[no-]string-extโ enables or disables the String extension ๐งต-m[no-]reduced-regsโ enables or disables the Reduced Register configuration (GPR16) option ๐ชถ-m[no-]audio-isa-extโ enables or disables the AUDIO ISA extension ๐ถ-m[no-]fpu-sp-extโ enables or disables the FPU SP extension ๐ข-m[no-]fpu-dp-extโ enables or disables the FPU DP extension ๐ข๐ข-m[no-]fpu-fmaโ enables or disables the FPU fused-multiply-add instructions ๐งฎ-mall-extโ turns on support for all extensions and instructions ๐
The following options are available when as is configured for a PowerPC processor. ๐
-a32โ generates ELF32 or XCOFF32 ๐-a64โ generates ELF64 or XCOFF64 ๐-K PICโ setsEF_PPC_RELOCATABLE_LIBin ELF flags ๐ท๏ธ-mpwrx,-mpwr2โ generates code for POWER/2 (RIOS2) ๐ฐ๏ธ-mpwrโ generates code for POWER (RIOS1) ๐-m601โ generates code for PowerPC 601 ๐น๏ธ-mppc,-mppc32,-m603,-m604โ generates code for PowerPC 603/604 ๐ฟ-m403,-m405โ generates code for PowerPC 403/405 ๐ผ-m440โ generates code for PowerPC 440, BookE and some 405 instructions ๐-m464โ generates code for PowerPC 464 ๐๏ธ-m476โ generates code for PowerPC 476 ๐ฌ-m7400,-m7410,-m7450,-m7455โ generates code for PowerPC 7400/7410/7450/7455 ๐บ-m750cl,-mgekko,-mbroadwayโ generates code for PowerPC 750CL/Gekko/Broadway ๐ฎ-m821,-m850,-m860โ generates code for PowerPC 821/850/860 ๐จ๏ธ-mppc64,-m620โ generates code for PowerPC 620/625/630 ๐ง-me200z2,-me200z4โ generates code for e200 variants, where e200z2 comes with LSP and e200z4 comes with SPE ๐-me300โ generates code for the PowerPC e300 family ๐-me500,-me500x2โ generates code for the Motorola e500 core complex ๐๏ธ-me500mcโ generates code for the Freescale e500mc core complex ๐ต-me500mc64โ generates code for the Freescale e500mc64 core complex ๐บ-me5500โ generates code for the Freescale e5500 core complex ๐-me6500โ generates code for the Freescale e6500 core complex ๐-mlspโ enables LSP instructions (this disables SPE and SPE2) ๐-mspeโ generates code for Motorola SPE instructions (this disables LSP) ๐-mspe2โ generates code for Freescale SPE2 instructions (this disables LSP) ๐-mtitanโ generates code for the AppliedMicro Titan core complex ๐ป-mppc64bridgeโ generates code for PowerPC 64, including bridge insns ๐-mbookeโ generates code for 32-bit BookE ๐-ma2โ generates code for the A2 architecture ๐งช-maltivecโ generates code for processors with AltiVec instructions ๐น-mvleโ generates code for Freescale PowerPC VLE instructions ๐งพ-mvsxโ generates code for processors with Vector-Scalar (VSX) instructions ๐-mhtmโ generates code for processors with Hardware Transactional Memory instructions ๐งพ-mpower4,-mpwr4โ generates code for the Power4 architecture ๐-mpower5,-mpwr5,-mpwr5xโ generates code for the Power5 architecture ๐๐-mpower6,-mpwr6โ generates code for the Power6 architecture โก-mpower7,-mpwr7โ generates code for the Power7 architecture โกโก-mpower8,-mpwr8โ generates code for the Power8 architecture ๐-mpower9,-mpwr9โ generates code for the Power9 architecture ๐๐-mpower10,-mpwr10โ generates code for the Power10 architecture ๐ซ-mpower11,-mpwr11โ generates code for the Power11 architecture ๐-mfutureโ generates code for the 'future' architecture ๐ฎ-mcellโ generates code for the Cell Broadband Engine architecture ๐ฑ-mcomโ generates code for Power/PowerPC common instructions ๐ค-manyโ generates code for any architecture (PWR/PWRX/PPC) ๐-mregnamesโ allows symbolic names for registers ๐ท๏ธ-mno-regnamesโ does not allow symbolic names for registers ๐ โโ๏ธ-mrelocatableโ supports GCC's-mrelocatableoption ๐งญ-mrelocatable-libโ supports GCC's-mrelocatable-liboption ๐งญ๐งญ-membโ sets the PPC_EMB bit in ELF flags ๐งท-mlittle,-mlittle-endian,-leโ generates code for a little endian machine ๐
Okay, the RISC-V stuff is next, so let's get into it ๐
-mbig,-mbig-endian,-beโ generates code for a big endian machine ๐ธ-msolarisโ generates code for Solaris โจ-mno-solarisโ nope, does NOT generate code for Solaris ๐ โโ๏ธ-nops=countโ if an alignment directive would insert more thancountnops, it puts a branch at the beginning so the nops get skipped and never actually run ๐ง
๐ RISC-V ๐
Okay, these only show up when as is configured for a RISC-V processor, so keep that in mind, bestie ๐ฆ
-fpic,-fPICโ generates position-independent code ๐-fno-picโ doesn't generate position-independent code. This is the default ๐-march=ISA|Profiles|Profiles_ISAโ picks the base isa, whether you pass it as ISA, Profiles, or Profies_ISA. For example:-march=rv32ima,-march=RVI20U64,-march=RVI20U64_d. If this option and the architecture attributes aren't set, the assembler checks the default configure setting--with-arch=ISAinstead ๐ฅ-misa-spec=ISAspecโ picks the default isa spec version. If the ISA version isn't set by-march, the assembler helps out by setting the version based on the default spec it chose. If this option isn't set, the assembler checks the default configure setting--with-isa-spec=ISAspec๐-mpriv-spec=PRIVspecโ picks the privileged spec version. This decides whether a CSR is valid or not based on the spec you chose. If this option and the privilege attributes aren't set, the assembler checks the default configure setting--with-priv-spec=PRIVspec๐-mabi=ABIโ selects the ABI, which is either"ilp32"or"lp64". You can optionally tack on"f","d", or"q"to say you want the single-precision, double-precision, or quad-precision floating-point calling convention. Or you can use none of those, or"e", to get the soft-float calling convention ("e"means a soft-float RVE ABI) ๐-mrelaxโ takes advantage of linker relaxations to cut down the number of instructions needed to materialize symbol addresses. This is the default โจ-mno-relaxโ no linker relaxations for you ๐ โโ๏ธ-march-attrโ generates the default contents for the riscv elf attribute section, but only if the.attributedirectives aren't set. This section records the info a linker or runtime loader needs to check compatibility. That includes the ISA string, the stack alignment requirement, unaligned memory accesses, and the major, minor and revision version of the privileged spec ๐ง-mno-arch-attrโ doesn't generate the default riscv elf attribute section if the.attributedirectives aren't set ๐ซถ-mcsr-checkโ enables CSR checking for the ISA-dependent CRS and the read-only CSR. ISA-dependent CSRs are only valid when the specific ISA is set. Read-only CSRs can't be written by the CSR instructions ๐-mno-csr-checkโ no CSR checking, bestie ๐-mlittle-endianโ generates code for a little endian machine ๐ท-mbig-endianโ generates code for a big endian machine ๐ธ
For the RX-specific options, go check the info pages, because they've got the full tea on those ๐
๐ง s390 ๐ง
These options are available when as is configured for the s390 processor family ๐
-m31,-m64โ picks the word size, either 31/32 bits or 64 bits ๐ฅ-mesa,-mzarchโ picks the architecture mode, either the Enterprise System Architecture (esa) or the z/Architecture mode (zarch) ๐๏ธ-march=processorโ tells it which s390 processor variant is the target. You can chooseg5(orarch3),g6,z900(orarch5),z990(orarch6),z9-109,z9-ec(orarch7),z10(orarch8),z196(orarch9),zEC12(orarch10),z13(orarch11),z14(orarch12),z15(orarch13),z16(orarch14), orz17(orarch15) โญ-mregnames,-mno-regnamesโ allows or disallows symbolic names for registers ๐-mwarn-areg-zeroโ warns whenever the operand for a base or index register has been specified but evaluates to zero โ ๏ธ-mwarn-regtype-mismatch=strict,-mwarn-regtype-mismatch=relaxed,-mwarn-regtype-mismatch=no,-mno-warn-regtype-mismatchโ controls whether the assembler does register name type checks and throws a warning when there's a mismatch with the operand register type. The default, which you can get back with therelaxedargument, does relaxed checks. Those let floating point register (FPR) names%f0to%f15be used as arguments for vector register (VR) operands, and vector register (VR) names%v0to%v15be used for floating point register (FPR) operands. That's fine because the FPRs are embedded in the lower half of the VR ๐ซง. With thestrictargument, the strict register name type checks happen. Thenoargument, which is the same as-mno-warn-regtype-mismatch, turns off all register name type checks ๐
๐ฆ TMS320C6000 ๐ฆ
These options are available when as is configured for a TMS320C6000 processor ๐ง
-march=archโ only enables instructions from architecturearch. By default, all instructions are allowed ๐
The accepted values of arch are "c62x", "c64x", "c64x+", "c67x", "c67x+", and "c674x" โจ
-mdsbt,-mno-dsbtโ the-mdsbtoption makes the assembler generate the"Tag_ABI_DSBT"attribute with a value of 1, which means the code uses DSBT addressing. The-mno-dsbtoption, the default, makes the tag have a value of 0, which means the code doesn't use DSBT addressing. The linker will warn you if objects of different type (DSBT and non-DSBT) get linked together โ ๏ธ-mpid=no,-mpid=near,-mpid=farโ the-mpid=option makes the assembler generate the"Tag_ABI_PID"attribute, with a value showing what kind of data addressing the code uses.-mpid=no, the default, means position-dependent data addressing.-mpid=nearmeans position-independent addressing with GOT accesses using near DP addressing.-mpid=farmeans position-independent addressing with GOT accesses using far DP addressing. The linker will warn you if objects built with different settings of this option get linked together ๐-mpic,-mno-picโ the-mpicoption makes the assembler generate the"Tag_ABI_PIC"attribute with a value of 1, meaning the code uses position-independent code addressing. The"-mno-pic"option, the default, gives the tag a value of 0, meaning position-dependent code addressing. The linker will warn you if objects of different type (position-dependent and position-independent) get linked together ๐-mbig-endian,-mlittle-endianโ generates code for the endianness you specify. The default is little-endian ๐ท
๐ TILE-Gx ๐
These options are available when as is configured for a TILE-Gx processor ๐
-m32 | -m64โ picks the word size, either 32 bits or 64 bits ๐ฅ-EB | -ELโ picks the endianness, either big-endian (-EB) or little-endian (-EL) ๐ซถ
๐ธ Visium ๐ธ
This option is available when as is configured for a Visium processor ๐ฝ
-mtune=archโ specifies the target architecture. If you try to assemble an instruction that won't execute on the target architecture, the assembler throws an error message at you ๐ญ
The names it recognizes are "mcm24", "mcm", "gr5", and "gr6" ๐
๐ Xtensa ๐
These options are available when as is configured for an Xtensa processor ๐
--text-section-literals,--no-text-section-literalsโ controls how literal pools get treated. The default is--no-text-section-literals, which puts literals in separate sections in the output file, so the literal pool can live in data RAM/ROM. With--text-section-literals, the literals get interspersed in the text section so they stay as close as possible to their references. You might need this for big assembly files, where the literals would otherwise be out of range of the"L32R"instructions in the text section. Literals get grouped into pools following".literal_position"directives or right before"ENTRY"instructions. These options only affect literals referenced via PC-relative"L32R"instructions. Literals for absolute mode"L32R"instructions are handled separately ๐งฉ--auto-litpools,--no-auto-litpoolsโ also controls how literal pools get treated. The default is--no-auto-litpools, which, when--text-section-literalsisn't used, puts literals in separate sections in the output file so the literal pool can live in data RAM/ROM. With--auto-litpools, the literals get interspersed in the text section to stay as close as possible to their references, and you don't need explicit".literal_position"directives. This can be necessary for very large functions, where one literal pool at the beginning of the function might not be reachable by"L32R"instructions at the end. These options only affect literals referenced via PC-relative"L32R"instructions. Literals for absolute mode"L32R"instructions are handled separately. When you use it together with--text-section-literals,--auto-litpoolstakes precedence ๐--absolute-literals,--no-absolute-literalsโ tells the assembler whether"L32R"instructions use absolute or PC-relative addressing. If the processor includes the absolute addressing option, the default is to use absolute"L32R"relocations. Otherwise, only the PC-relative"L32R"relocations can be used ๐--target-align,--no-target-alignโ enables or disables automatic alignment to reduce branch penalties, at some expense in code size. This optimization is on by default. Note that the assembler will always align instructions like"LOOP"that have fixed alignment requirements ๐โโ๏ธ--longcalls,--no-longcallsโ enables or disables transforming call instructions so calls can reach a greater range of addresses. Use this when call targets might be out of range. It may hurt both code size and performance, but the linker can usually optimize away the unnecessary overhead when a call ends up within range. The default is--no-longcalls๐--transform,--no-transformโ enables or disables all assembler transformations of Xtensa instructions, including both relaxation and optimization. The default is--transform. Only use--no-transformin the rare cases when the instructions must be exactly as you wrote them in the assembly source. Using--no-transformmakes out of range instruction operands into errors ๐จ
the rename option: --rename-section oldname=newname. Rename the oldname section to newname, and you can repeat this one as many times as you need to rename several sections. ๐
--trampolines|--no-trampolines: Turns on (or off) rewriting of jump instructions so they can reach a wider range of addresses. Reach for this when jump targets might be out of range. If there are no such jumps, it doesn't change code size or performance at all. The default is--trampolines. ๐ฆ--abi-windowed|--abi-call0: Picks the ABI tag that gets written into the.xtensa.infosection, which tells everyone what ABI the assembly code uses. The linker will warn you if you try to link object files with mismatched ABI tags, so be careful, bestie ๐ญ. If you don't choose, the default comes from the Xtensa core configuration. ๐
The following options are available when as is configured for a Z80 processor. โจ
@chapter Z80 Dependent Features
โจ Command-line Options โจ
-march=CPU[-EXT...][+EXT...]: Picks the target processor. If you try to assemble an instruction that won't run on that processor, the assembler throws an error at you ๐. These processor names are recognised:"z80","z180","ez80","gbz80","z80n","r800". Beyond the basic instruction set, you can also ask for some extension mnemonics. For example,-march=z180+sli+infcextends z180 with SLI instructions andIN F,(C). These extensions are currently supported:"full"(all known instructions)"adl"(ADL CPU mode by default, eZ80 only)"sli"(instruction known as SLI, SLL or SL1)"xyhl"(instructions with halves of index registers: IXL, IXH, IYL, IYH)"xdcb"(instructions like RotOp (II+d),R and BitOp n,(II+d),R)"infc"(instruction IN F,(C) or IN (C))"outc0"(instruction OUT (C),0)
Quick heads up: instead of adding onto a basic set, extensions starting with - revoke that functionality ๐. For example, -march=z80-full+xyhl first strips out all default extensions, then adds support for index register halves only.
If you don't specify this option, the assembler assumes -march=z80+xyhl+infc. ๐ธ
-local-prefix=prefix: Marks every label starting with the given prefix as local. You can still explicitly mark one of those labels as global in your code, though ๐ง. This doesn't change the default local label prefix.L, it just adds a new one alongside it.-colonless: Accepts labels without colons. Every symbol at the start of a line gets treated as a label โจ.-sdcc: Accepts assembler code produced by SDCC ๐.-fp-s=FORMAT: Sets the format for single precision floating point numbers. The default isieee754(32 bit).-fp-d=FORMAT: Sets the format for double precision floating point numbers. The default isieee754(64 bit).
โจ SEE ALSO โจ
gcc(1), ld(1), and the Info entries for binutils and ld. Go poke around those if you want more ๐ฅ.
โจ COPYRIGHT โจ
Copyright (c) 1991-2025 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". ๐ซถ
That's the whole AS page, bestie! You're officially a manual-reading legend now ๐๐ binutils 2.45, December 2025, no cap โจ๐
๐ฆ where this page comes from
- ubuntu questing: binutils-common 2.45-7ubuntu1.2
- ubuntu questing: binutils-x86-64-linux-gnu 2.45-7ubuntu1.2
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms