as -- common assembler


as [-mnRTV] [-dl] [-b type] [-o objfile] [-Q yn] [-t cpu] [-Y [md],dir] file


The as(CP) command produces an object file from the concatenation of the named assembly language input files. The default is to generate the object file in COFF format, unless the option -b elf is used, in which case an ELF binary is produced.

There must be at least one file argument, except when the -V option is given. Multiple input files are not allowed when generating a COFF binary. When the option -b elf is used, there can be multiple input files and the name -, designating the standard input, can appear anywhere within the list of files.

The recognized assembly language does not include a general macro processing capability. Instead, as provides for optional preprocessing of the input by the m4(CP) command.

Common options

The following options are common to producing both types of binary and may be specified in any order:

-b type
Produce the binary in type format. type can be one of coff (default), ibcs2 (equivalent to coff) and elf. The default is to produce the object file in COFF format.

Run the m4 macro processor on the input prior to assembly. All file operands are passed unmodified to the m4 command. If the predefined macros file, LIBDIR/cm4defs, is present, it is given to the m4 command as the initial input file. m4 options can also be preserved and passed through to the m4 command by using the -- option-terminator, when the option -b elf is used. See the ``Examples'' section.

-o objfile
Put the output of the assembly in the file objfile. If this option is not used, the name of the output file depends on the name of the input files (and the requested file format of the object file). The default output filename is always formed by taking the filename of the first input file that has a .s suffix and replacing the .s with a .o suffix. If no input filename has the .s suffix, the output file is a.out for ELF binaries and file.o for COFF binaries.

Write the assembler's packaging, release, and version information on the standard error output. As a special case, the assembler does no other processing if no input files are specified.

-Y [md],dir
Find the m4 preprocessor (m) and/or the file of predefined macros (d) in directory dir instead of in the customary place. For COFF format, there must be a space between the -Y flag and its options.

Options for COFF format

These options can be used to control how the COFF binaries are generated. They are effective only when the option -b elf is not used.

Do not produce line number information in the object file.

Turn off long/short address optimization. By default, address optimization takes place.

Remove (unlink) the input file after assembly is completed.

Options for ELF format

These options can be used to control how the ELF binaries are generated. They must be used with the option -b elf.

Accept input that contains COFF directives. Nevertheless, the object file produced is still in ELF format. In certain circumstances, the ELF binary generated may not be as effective as it would be in its corresponding native COFF format.

-Q yn
Append the assembler's release information to the .comment section of the generated output object file if yn is y; otherwise (if yn is n or if no -Q option is specified), nothing is added.

-t cpu
Specify the target processor to be cpu, which may be one of 486 (the default), 386, or pentium (the Intel Pentium(TM) processor). This option causes code generation specifically tuned to the selected processor.

Exit values

Upon successful completion, the exit status of as is 0, otherwise the exit status is non-zero.


The .even assembler directive may not work in the .text section for COFF format binaries when optimization is performed.

Arithmetic expressions may only have one forward referenced symbol per expression.

Wherever possible, the assembler should be accessed through a compilation system interface program such as cc(CP).


If the -m option (m4 macro processor invocation) is used, keywords for m4 (index and len, for example) cannot be used as symbols (variables, functions, labels) in the input file since m4 cannot determine which are assembler symbols and which are real m4 macros.


The following command example,

as -b elf -m -Yd,. --  -DK=7 mydefs sys/file.s

sends, in order, ./cm4defs (if it exists) and mydefs and sys/file.s through m4 with the macro K predefined to be 7, assembles the output of m4, and generates the ELF object file output in ./file.o.




temporary files

TMPDIR is usually /usr/tmp but can be redefined by setting the environment variable TMPDIR. See tempnam() in tmpnam(S).

language-specific message file. See LANG in localedef(F).

See also

a.out(FP), cc(CP), elf(S), ld(CP), m4(CP), nm(CP), strip(CP), tmpnam(S)

Standards conformance

as is not part of any currently supported standard; it was developed by UNIX System Laboratories, Inc. and is used by permission.
© 2003 Commands for Programming (CP)
SCO OpenServer Release 5.0.7 -- 11 February 2003