GNU Assembler
Encyclopedia
The GNU Assembler, commonly known as GAS (even though the program itself is as), is the assembler used by the GNU Project
GNU Project
The GNU Project is a free software, mass collaboration project, announced on September 27, 1983, by Richard Stallman at MIT. It initiated GNU operating system development in January, 1984...

. It is the default back-end of GCC
GNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

. It is used to assemble the GNU operating system and the Linux kernel
Linux kernel
The Linux kernel is an operating system kernel used by the Linux family of Unix-like operating systems. It is one of the most prominent examples of free and open source software....

, and various other software. It is a part of the GNU Binutils package.

GAS' executable
Executable
In computing, an executable file causes a computer "to perform indicated tasks according to encoded instructions," as opposed to a data file that must be parsed by a program to be meaningful. These instructions are traditionally machine code instructions for a physical CPU...

 is named after as
As (Unix)
as is a generic name for an assembler on Unix. The GNU Project's assembler is named Gas....

, a Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 assembler. GAS is cross-platform
Cross-platform
In computing, cross-platform, or multi-platform, is an attribute conferred to computer software or computing methods and concepts that are implemented and inter-operate on multiple computer platforms...

, and both runs on and assembles for a number of different computer architecture
Computer architecture
In computer science and engineering, computer architecture is the practical art of selecting and interconnecting hardware components to create computers that meet functional, performance and cost goals and the formal modelling of those systems....

s. Released under the GNU General Public License
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

 v3, GAS is free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

.

General syntax

GAS supports a general syntax that works for all of the supported architectures. The general syntax includes assembler directives and a method for commenting.

Directives

GAS uses assembler directives
Directive (programming)
In computer programming, the term directive is applied in a variety of ways that are similar to the term command. It is also used to describe some programming language constructs ....

 (also known as pseudo ops), which are keywords beginning with a period that behave similarly to preprocessor directives in the C programming language
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

. While most of the available assembler directives are valid regardless of the target architecture, some directives are machine dependent.

Comments

GAS comments start with a number sign
Number sign
Number sign is a name for the symbol #, which is used for a variety of purposes including, in some countries, the designation of a number...

 and span up to a newline
Newline
In computing, a newline, also known as a line break or end-of-line marker, is a special character or sequence of characters signifying the end of a line of text. The name comes from the fact that the next character after the newline will appear on a new line—that is, on the next line below the...

 character. Example:

  1. comment

popl %edx # comment

Criticism

One source of criticism was that on the x86 and x86-64
X86-64
x86-64 is an extension of the x86 instruction set. It supports vastly larger virtual and physical address spaces than are possible on x86, thereby allowing programmers to conveniently work with much larger data sets. x86-64 also provides 64-bit general purpose registers and numerous other...

 architecture it uses the AT&T assembler syntax, rather than the Intel syntax used in many other assemblers; however, in versions from 2.10 support for the Intel syntax via the .intel_syntax directive has been added.

Here is the example as C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

-inline assembler
Inline assembler
In computer programming, the inline assembler is a feature of some compilers that allows very low level code written in assembly to be embedded in a high level language like C or Ada...

 in Intel syntax:

__asm__ __volatile__(".intel_syntax noprefix\n\t"
"pop edx\n\t"
"mov eax,edx\n\t"
".att_syntax prefix\n\t"
: /* no outputs */
: "d" (save_var), "a" (temp_var) /* inputs */
: "eax", "edx" /* clobber list */);

See also

  • GNU toolchain
    GNU toolchain
    The GNU toolchain is a blanket term for a collection of programming tools produced by the GNU Project. These tools form a toolchain used for developing applications and operating systems....

  • Binary File Descriptor library
  • List of assemblers

External links

  • Gas manual
  • A comparison of GAS and NASM at IBM
    IBM
    International Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK