GNU Assembler

From Wikipedia, the free encyclopedia
Jump to: navigation, search
GNU Assembler
Developer(s) GNU Project
Stable release 2.21 / December 8, 2010; 12 months ago (2010-12-08)
Written in C
Platform Cross-platform
Type Assembler
License GNU General Public License v3
Website www.gnu.org/software/binutils

The GNU Assembler, commonly known as GAS (even though the program itself is as), is the assembler used by the GNU Project. It is the default back-end of GCC. It is used to assemble the GNU operating system and the Linux kernel, and various other software. It is a part of the GNU Binutils package.

GAS' executable is named after as, a Unix assembler. GAS is cross-platform, and both runs on and assembles for a number of different computer architectures. Released under the GNU General Public License v3, GAS is free software.

Contents

[edit] 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.

[edit] Directives

GAS uses assembler directives (also known as pseudo ops), which are keywords beginning with a period that behave similarly to preprocessor directives in the C programming language. While most of the available assembler directives are valid regardless of the target architecture, some directives are machine dependent.[1]

[edit] Comments

GAS comments start with a number sign and span up to a newline character. Example:

# comment
popl %edx # comment

[edit] Criticism

One source of criticism was that on the x86 and x86-64 architecture it uses the AT&T assembler syntax, rather than the Intel syntax used in many other assemblers; however, in versions from 2.10[2] support for the Intel syntax via the .intel_syntax directive has been added.[3][4]

Here is the example as C-inline assembler in Intel syntax:

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

[edit] See also

[edit] References

[edit] External links

Personal tools
Namespaces
Variants
Actions
Navigation
Interaction
Toolbox
Print/export
Languages