LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

as

Translate assembly language source into object files.

TLDR

Assemble a file, writing output to a.out
$ as [path/to/file.s]
copy
Assemble to a specific output file
$ as [path/to/file.s] -o [path/to/output.o]
copy
Generate output faster by skipping whitespace preprocessing
$ as -f [path/to/file.s]
copy
Add a directory to the include search path
$ as -I [path/to/directory] [path/to/file.s]
copy

SYNOPSIS

as [options] file...

DESCRIPTION

as is the GNU assembler, part of the GNU Binutils collection. It translates assembly language source files into object files that can be linked with ld to create executables.While primarily intended to assemble output from compilers like gcc, it can also be used directly for low-level programming. The assembler supports multiple target architectures and output formats.

PARAMETERS

-o file

Write the output object file to file instead of a.out
-f
Fast mode: skip whitespace and comment preprocessing (use only with trusted compiler output)
-I directory
Add directory to the search path for .include directives
-g
Generate debugging information
--32 / --64
Generate 32-bit or 64-bit code (x86)
-W, --no-warn
Suppress warning messages.
--warn
Do not suppress warnings (default).
--fatal-warnings
Treat warnings as errors.
-a[letters]
Turn on listings; suboptions include h (high-level), l (assembly), s (symbols), n (omit forms processing).
--statistics
Print processing statistics (max-space, total-time).
-march=CPU
Assemble for a specific CPU architecture.

CAVEATS

Assembly syntax varies between architectures. GNU as uses AT&T syntax by default on x86, which differs from Intel syntax. Use .intel_syntax noprefix directive for Intel syntax. The -f flag should only be used with compiler-generated output, since it skips whitespace and comment preprocessing that hand-written sources may rely on.

HISTORY

The GNU assembler was developed as part of the GNU project starting in the 1980s. It became part of GNU Binutils and supports virtually all architectures that GCC targets.

SEE ALSO

gcc(1), ld(1), objdump(1), readelf(1)

Copied to clipboard
Kai