Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
cc command in Linux with Examples
Next article icon

as command in linux with examples

Last Updated : 18 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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
IMG20210908155122min-copy-2


IMG20210908155135min-copy-2


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

Next Article
cc command in Linux with Examples

B

bhukyavasanthkumar
Improve
Article Tags :
  • Linux-Unix
  • linux-command
  • Linux-system-commands

Similar Reads

  • aspell command in Linux with examples
    aspell command is used as a spell checker in Linux. Generally, it will scan the given files or anything from standard input then it check for misspellings. Finally, it allows the user to correct the words interactively. Spell checking is crucial when working with large documents, coding, or writing
    3 min read
  • cc command in Linux with Examples
    'cc' command stands for C Compiler, usually an alias command to 'gcc' or 'clang'. As the name suggests, executing the 'cc' command will usually call the 'gcc' on Linux systems. It is used to compile the C language codes and create executables. The number of options available for the cc command is ve
    3 min read
  • bison command in Linux with Examples
    bison command is a replacement for the yacc. It is basically a parser generator similar to yacc. Input files should follow the yacc convention of ending in .y format. Similar to yacc, the generated files do not have fixed names, but instead use the prefix of the input file. Moreover, if you need to
    4 min read
  • adduser command in Linux with Examples
    adduser command in Linux is used to add a new user to your current Linux machine. This command allows you to modify the configurations of the user which is to be created. It is similar to the useradd command in Linux. The adduser command is much interactive as compared to useradd command. Installing
    4 min read
  • apropos command in Linux with Examples
    Linux/Unix comes with a huge number of commands and thus it become quite difficult sometimes to remember each and every command. apropos command becomes useful in such cases. apropos command helps the user when they don't remember the exact command but knows a few keywords related to the command tha
    3 min read
  • 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
  • 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
  • gs command in Linux with Examples
    gs command invokes Ghostscript, which is an interpreter of Adobe Systems PostScript and Portable Document Format(PDF) languages. After executing Ghostscript it reads further input from the standard input stream until it encounters 'quit' command. Syntax: gs [ options ] [ files ] ... Options: Below a
    2 min read
  • df command in Linux with Examples
    Ever felt the chilling fear of a "disk full" error message on your Linux machine? Fear not, for the mighty df command stands ready to guide you through the treacherous terrain of disk space management! This article delves deep into the df command, equipping you with the knowledge and skills to navig
    5 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
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences