as command in linux with examples
Last Updated :
18 Jun, 2024
as command is the portable GNU assembler in Linux. Using as command, we can read and assemble a source file.
- The main purpose of ‘as‘ is to assemble the output of the GNU compiler of the C language.
- as command reads and assembles the .s File. Also, whenever you do not specify the file, it normally reads, assembles the STDIN.
- Output is stored in a file named a.out and the format of the file is XCOFF.
Note: Source file i.e .s file is an extension for source files that are written in assembly languages.Â
Syntax:
as [ -a Mode ] [ -o ObjectFile ] [ -n Name ] [ -u ] [ -l [ ListFile ] ] [ -W | -w ] [ -x [ XCrossFile ] ] [ -s [ ListFile ]] [ -m ModeName ][-M][-Eoff|on ] [ -p off|on ] [ -i ] [ -v ] [ File ]
Note:
- Location of command in Linux Directory: /usr/ccs/bin/as
- Output : a.out
Options:
To display all options use the command help:Â
Syntax:
as --help
Options for as command with examples
1. creating .s files
.s source files are associated with the GNU Assembler.Â
Input:

Output:

.s file :

2. as: gives out files as output after applying the command
Consider the sample .s file which we have generated using the above example, So now applying as command to the sample.s file, we will be generating an a.out file.Â
Syntax:
as sample.s
Output :

Note: The following options are optionalÂ
3. -a: In General, as command will be operating in 32-bit mode. Using the -a command, we can know in which mode as command is operating. This mode can also be set by using -a32 if we need a 32-bit operation / -a64 if we need a 64-bit operation.Â
Consider the above sample.s file which we have generated using sample.c program. Applying -a to the file will list the understanding of the .s  code that has been generated.
Syntax:Â
as sample.s -a
Output:

4. -v: This option can be used to display the version number.Â
Consider the sample.s file which we have generated using the above example, So now applying the -v option to the sample.s file, we will know the version.Â
Syntax:Â
as sample.s -v
Output:

5. -D:Â This has no effect. Â It is accepted to make it more likely that the scripts that are written for other assemblers will also work with the as command.Â
Example: consider the option with the sample. s program
Syntax:Â
as sample.s -D

6. –MD: Using this option, as can make a dependency file for the file it creates. The file contains dependencies of the main source file.Â
Example: We need to use a filename in an argument. Consider the sample.s file
Main Use: This feature is used in the automatic updating of makefiles.
Syntax:Â
as sample.s --MD two

7. –statistics: This will be displaying the statistics of resources used by the as command.Â
Note: The result will be in the format, the maximum amount of space allocated during the assembly, Â total execution time taken for the assembly.
In bytes and CPU Seconds respectively.Â
Syntax:Â
as sample.s --statistics

Similar Reads
autoscan command in Linux with Examples
autoscan command in Linux is used to generate a preliminary configure.in file. Basically, this command will check the source file in the directory tree rooted at SRCDIR, or the current directory if none is given. It also searches the source files for common portability problems, check for the incomp
2 min read
ed command in Linux with examples
Linux 'ed' command is used to start the ed text editor, a very minimal fronted line-based text editor. The lines are very simple in relation to other text files, hence easy to work on, for creating as well as editing, display, and manipulation of files. Since it was the first editor that was include
4 min read
dc command in Linux with examples
The dc command is a versatile calculator found in Linux systems, operating using reverse Polish notation (RPN). This command allows users to perform arithmetic calculations and manipulate a stack, making it ideal for complex mathematical tasks directly from the command line. SyntaxThe basic syntax f
3 min read
amixer command in Linux with Examples
amixer is a command-line mixer for ALSA(Advanced Linux Sound Architecture) sound-card driver . amixer can support multiple soundcards. amixer with no arguments will display the current mixer settings for the default soundcard as well as the device. This is a good way to see a list of the simple mixe
2 min read
ex command in Linux with examples
ex (stands for extended) is a text editor in Linux which is also termed as the line editor mode of the vi editor. This editor simply provided some editing commands which has greater mobility. With the help of this editor, a user can easily move between files. Also, he/she has a lot of ways to transf
4 min read
gcc command in Linux with examples
GCC stands for GNU Compiler Collections which is used to compile mainly C and C++ language. It can also be used to compile Objective C and Objective C++. The most important option required while compiling a source code file is the name of the source program, rest every argument is optional like a wa
2 min read
yes command in Linux with Examples
yes, the command in Linux is used to print a continuous output stream of a given STRING. If STRING is not mentioned then it prints 'y'; Syntax: of `yes` command in Linuxyes [STRING] Note: To stop printing please press Ctrl + C. Use of `yes` commandlet us say that we want to delete all the `.txt` fil
2 min read
apt-get command in Linux with Examples
The command-line tool `apt-get` is the most popular package management tool used in our Debian-based Linux operating system. This article provides an overview of `apt-get` and its basic syntax. It will include the most commonly used commands, their syntax, description, and examples. It also gives an
15+ min read
automake command in Linux with Examples
automake is a tool used for automatically generating Makefile.in files compliant with the set GNU Coding Standards. autoconf is required for the use of automake. automake manual can either be read on-line or downloaded in the PDF format. More formats are also offered for download or on-line reading.
1 min read
autoconf command in Linux with examples
autoconf command is used in Linux to generate configuration scripts. Generate a configuration script from a TEMPLATE-FILE if given, or from âconfigure.acâ if present, or 'configure.in'. The output is sent to the standard output if TEMPLATE-FILE is given, otherwise, it is sent into âconfigureâ. To us
1 min read