x86 Assembly Language Reference Manual

Exit Print View

Updated: December 2014

Using the Assembler Command Line

This appendix describes how to invoke the assembler from the command line, and details the command-line options.

A.1 Assembler Command Line

You invoke the assembler command line as follows:

as [options] [inputfile] ... 

Note - The Oracle Solaris Studio C, C++, and Fortran compilers (cc(1), CC(1), and f95(1)) invoke the assembler with the fbe command. You can use either the as or fbe command on a Oracle Solaris platform to invoke the assembler. On an Oracle Solaris x86 platform, the as or fbe command will invoke the x86 assembler. On an Oracle Solaris SPARC platform, the command invokes the SPARC assembler.

The as command translates the assembly language source files, inputfile, into an executable object file, objfile. The assembler recognizes the filename argument hyphen (-) as the standard input. It accepts more than one file name on the command line. The input file is the concatenation of all the specified files. If an invalid option is given or the command line contains a syntax error, the assembler prints the error (including a synopsis of the command line syntax and options) to standard error output, and then terminates.

The assembler supports macros, #include files, and symbolic substitution through use of the C preprocessor cpp(1). The assembler invokes the preprocessor before assembly begins if it has been specified from the command line as an option. (See the -P option.)

A.2 Assembler Command Line Options


Allow 32–bit addresses in 64–bit mode.

-Dname -Dname=def

When the -P option is in effect, these options are passed to the cpp preprocessor without interpretation by the as command; otherwise, they are ignored.


Enable (-H) or suppress (-nH) generation of the Hardware Capabilities section.


When the -P option is in effect, this option is passed to the cpp preprocessor without interpretation by the as command; otherwise, it is ignored.


Ignore line number information from the preprocessor.


Check for address referencing with absolute relocation and issue warning.


This option runs m4 macro preprocessing on input. The m4 preprocessor is more useful for complex preprocessing than the C preprocessor invoked by the -P option. See the m4(1) man page for more information about the m4 macro-processor.


Select the 64–bit (-m64) or 32–bit (-m32) memory model. With –m64, the resulting .o object files are in 64-bit ELF format and can only be linked with other object files in the same format. The resulting executable can only be run on a 64-bit x86 processor running 64-bit Oracle Solaris OS. –m32 is the default.


Suppress all warnings while assembling.

-o outfile

Write the output of the assembler to outfile. By default, if –o is not specified, the output file name is the same as the input file name with .s replaced with .o.


Run cpp(1), the C preprocessor, on the files being assembled. The preprocessor is run separately on each input file, not on their concatenation. The preprocessor output is passed to the assembler.


This option produces the “assembler version” information in the comment section of the output object file if the y option is specified; if the n option is specified, the information is suppressed.


Produces a disassembly of the emitted code to the standard output. Adding each of the following characters to the -S option produces:

  • a - disassembling with address

  • b - disassembling with ".bof"

  • c - disassembling with comments

  • l - disassembling with line numbers

Capital letters turn the switch off for the corresponding option.


This option places all stabs in the ".stabs" section. By default, stabs are placed in "stabs.excl" sections, which are stripped out by the static linker ld during final execution. When the -s option is used, stabs remain in the final executable because ".stab" sections are not stripped out by the static linker ld.


When the -P option is in effect, this option is passed to the cpp preprocessor without interpretation by the as command; otherwise, it is ignored.


This option writes the version information on the standard error output.


processor specifies the target architecture processor. When there is a choice between several possible encodings, choose the one that is appropriate for the stated chip. In particular, use the appropriate no-op byte sequence to fill code alignment padding, and warn when instructions not defined for the stated chip are used.The assembler accepts the instruction sets for the following recognized -xchip processor values:

processor value
Target Processor
Generic x86
This host processor.
Intel Core2
Intel Nehalem
AMD Opteron
Intel Penryn
Intel Pentium
Intel Pentium Pro
Intel Pentium 3.
Intel Pentium 4
Intel Sandy Bridge
Intel Westmere
Intel Ivy Bridge
Intel Hawell

-xmodel=[small | medium | kernel]

For -m64 only, generate R_X86_64_32S relocatable type for data access under kernel. Otherwise, generate R_X86_64_32 under small. SHN_AMD64_LCOMMON and .lbcomm support added under medium. The default is small.


Specify the path to locate the version of cm4defs (-Yd,path) or m4 (-Ym,path) to use.


Indicate path to search for #include header files.

A.3 Disassembling Object Code

The dis program is the object code disassembler for ELF. It produces an assembly language listing of the object file. For detailed information about this function, see the dis(1) man page.