GNU Assembler

Developer(s)| GNU Project
Stable release|

GNU Binutils / Error: first parameter is missing. ()

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 or as, is the assembler developed 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. GAS is free software released under the GNU General Public License v3.

## Contents

* 1 History
* 2 General syntax
* 2.1 Directives
* 2.2 Comments
* 3 Usage
* 4 Example program
* 5 See also
* 6 References
* 7 External links

## History

The first version of GAS was released in 1986–1987.[1] It was written by Dean Elsner and supported the VAX architecture.[1]

## 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. The default syntax is AT&T syntax.

### 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.[2]

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

### Comments

GAS supports two comment styles.[6]

Multi-line

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

comment

Single-line

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

* A hash symbol (#) — i386, x86-64, i960, 68HC11, 68HC12, VAX, V850, M32R, PowerPC, MIPS, M680x0, and RISC-V
* A semicolon (;) — AMD 29k family, ARC, H8/300 family, HPPA, PDP-11, picoJava, Motorola, and M32C
* The at sign (@) — 32-bit ARM
* A double slash (//) — AArch64
* A vertical bar (|) — M680x0
* An exclamation mark (!) — Renesas SH

## Usage

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

## Example program

A standard "Hello, world!" program for Linux on IA-32:

.global	_start

.text
_start:
movl  $4, �x   # 4 (code for "write" syscall) -> EAX register
movl  $1, �x   # 1 (file descriptor for stdout) -> EBX (1st argument to syscall)
movl  $msg, �x # 32-bit address of msg string -> ECX (2nd argument)
movl  $len, �x # length of msg string -> EDX (3rd arg)
int   $0x80      # interrupt with location 0x80 (128), which invokes the kernel's system call procedure

movl  $1, �x   # 1 ("exit") -> EAX
movl  $0, �x   # 0 (with success) -> EBX
int   $0x80      # see previous
.data
msg:
.ascii  "Hello, world!\n" # inline ascii string
len =   . - msg           # assign (current address - address of msg start) to symbol "len"

## See also

* GNU toolchain
* Binary File Descriptor library
* Comparison of assemblers

## References

1. ↑ 1.0 1.1 "The GNU Assembler". CiteSeerX 10.1.1.32.4503.
2. ↑ "The GNU Assembler - Assembler Directives". http://sources.redhat.com/binutils/docs-2.12/as.info/Pseudo-Ops.html#Pseudo Ops.
3. ↑ "GNU Assembler News". https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/NEWS;hb=HEAD. "A new pseudo-op .intel_syntax has been implemented to allow gas to parse i386 assembly programs with intel syntax."
4. ↑ "AT&T Syntax versus Intel Syntax". http://sources.redhat.com/binutils/docs-2.12/as.info/i386-Syntax.html.
5. ↑ Ram Narayan (2007-10-17). "Linux assemblers: A comparison of GAS and NASM". IBM DeveloperWorks. http://www.ibm.com/developerworks/linux/library/l-gas-nasm.html.
6. ↑ Red Hat Inc.. "Using as". http://sources.redhat.com/binutils/docs-2.12/as.info/Comments.html#Comments.

## External links

| The Wikibook X86 Assembly has a page on the topic of: GAS Syntax

|

* No URL found. Please specify a URL here or add one to Wikidata.
* Gas manual
* `as(1)`: the portable GNU assembler – Linux User Commands Manual

* v
* t
* e

GNU Project

History|

* GNU Manifesto
* Free Software Foundation
* Europe
* India
* Latin America
* History of free software

Licenses|

* GNU General Public License
* linking exception
* font exception
* GNU Lesser General Public License
* GNU Affero General Public License
* GNU Free Documentation License

Software|

* GNU (variants)
* Hurd
* Linux-libre
* glibc
* Bash
* coreutils
* findutils
* Build System
* GCC
* binutils
* GDB
* GRUB
* GNOME
* GNUstep
* GIMP
* Jami
* GNU Emacs
* GNU TeXmacs
* GNU Octave
* GNU R
* GSL
* GMP
* GNU Electric
* GNU Archimedes
* GNUnet
* GNU Privacy Guard
* Gnuzilla (IceCat)
* GNU Health
* GNUmed
* GNU LilyPond
* GNU Go
* GNU Chess
* Gnash
* Guix
* Guix System Distribution
* more...

Public
speakers|

* Alexandre Oliva
* Benjamin Mako Hill
* Bradley M. Kuhn
* Federico Heinz
* Frédéric Couchet
* Georg C. F. Greve
* John Sullivan
* José E. Marchesi
* Joshua Gay
* Kefah T. Issa
* Loïc Dachary
* Nagarjuna G.
* Peter Heath
* Richard M. Stallman

Other topics|

* GNU/Linux naming controversy
* Revolution OS
* Free Software Foundation anti-Windows campaigns
* Defective by Design

* v
* t
* e

x86 assembly topics

Topics|

* Assembly language
* Comparison of assemblers
* Disassembler
* Instruction set
* Low-level programming language
* Machine code
* Microassembler
* x86 assembly language

Assemblers|

* A86/A386
* Flat Assembler (FASM)
* GNU Assembler (GAS)
* High Level Assembly (HLA)
* Microsoft Macro Assembler (MASM)
* Netwide Assembler (NASM)
* Turbo Assembler (TASM)
* Open Watcom Assembler (WASM)

Programming
issues|

* Call stack
* Flags
* Carry flag
* Direction flag
* Interrupt flag
* Overflow flag
* Zero flag
* Opcode
* Program counter
* Processor register
* Calling conventions
* Instruction listings
* Registers

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/GNU Assembler. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:GNU_Assembler&oldid=4136924"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template