GNU Assembler

From Wikipedia, the free encyclopedia
Jump to: navigation, search
GNU Assembler
Developer(s) GNU Project
Stable release 2.24 / December 2, 2013;
23 months ago
Written in C
Platform Cross-platform
Type Assembler
License GNU General Public License v3

The GNU Assembler, commonly known as gas or simply as, its executable name, 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.

The GAS executable is named as, the standard name for 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.

General syntax[edit]

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


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]


GAS supports two comment styles:[2]

Multi-line comments[edit]

As in C multi-line comments start and end with mirroring slash-asterisk pairs:


Single-Line comments[edit]

Single line comments have a few different formats varying on which architecture is being assembled for.


Being the back-end for a popular compiler suite, namely GCC, the GNU Assembler is very widely used in compiling modern open source software. GAS is often used as the assembler on GNU/Linux operating systems in conjunction with other GNU software. A modified version of GAS can also be found in the Macintosh operating system's development tools package since OS X.

Example Programs[edit]

A standard “Hello, world!” program for Linux on IA-32 using the default AT&T syntax:

.global	_start

	movl	$4, %eax
	movl	$1, %ebx
	movl	$msg, %ecx
	movl	$len, %edx
	int	$0x80

	movl	$1, %eax
	movl	$0, %ebx
	int	$0x80
	.ascii	"Hello, world!\n"
	len =	. - msg


Those more accustomed to writing in Intel syntax have argued that not supporting the Intel syntax for assembly on the x86 and x86-64 platforms, as many other assemblers do, is a flaw.

However, since version 2.10, Intel syntax can be used through use of the .intel_syntax directive.[3][4][5]

See also[edit]


  1. ^ "The GNU Assembler - Assembler Directives". 
  2. ^ Red Hat Inc. "Using as". Retrieved Jan 10, 2013. 
  3. ^ "GNU Assembler News". 
  4. ^ "AT&T Syntax versus Intel Syntax". Retrieved 28 July 2014. 
  5. ^ Ram Narayan (2007-10-17). "Linux assemblers: A comparison of GAS and NASM". IBM DeveloperWorks. Archived from the original on 3 Mar 2009. Retrieved 28 July 2014. 

External links[edit]