← 返回命令列表

Linux command

as 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Assemble

as [path/to/file.s]

Example

as [path/to/file.s] -o [path/to/output.o]

Example

as -f [path/to/file.s]

Example

as -I [path/to/directory] [path/to/file.s]

说明

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.

参数

-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.

FAQ

What is the as command used for?

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.

How do I run a basic as example?

Run `as [path/to/file.s]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o _file_ do in as?

Write the output object file to _file_ instead of a.out