GNU assembler

from Wikipedia, the free encyclopedia
GNU assembler

Heckert GNU white.svg
Basic data

developer GNU project
Publishing year 1986
Current  version 2.32
( February 2, 2019 )
operating system Cross-platform
programming language C.
category Assembler
License GNU General Public License v3
www.gnu.org/software/binutils

The GNU assembler , also known as GAS , is the assembler of the GNU project . It is the standard backend of the GNU Compiler Collection . It is used to assemble the GNU operating system, the Linux kernel and many other applications. It is part of the GNU Binutils package.

The executable file of the GNU assembler is named after the Unix assembler ( as ). GAS is cross-platform and can therefore be run and assembled for a large number of different computer architectures . GAS is released under the GNU General Public License v3 and is free software .

General syntax

The GNU assembler has a general syntax for all supported architectures. This syntax includes assembly language directives and methods for commenting.

Assembler directives

The GNU assembler uses assembler directives (also known as pseudo-ops), which are formed from a keyword starting with a period. Most of the available directives are architecture-independent, and a few are hardware-specific.

Comments

By default, GAS uses the pound sign ( #) for a single line comment. Example:

pop %edx # dies ist ein Kommentar
# dies ebenfalls
movl %edx,%eax

criticism

One source of criticism of GAS is that it uses the AT&T assembler syntax for the x86 and x64 architectures instead of the more common Intel syntax. However, this is due to the compatibility with GCC, and can be changed in newer versions via the directive .intel_syntax.

The above example in Intel syntax :

.intel_syntax noprefix
pop edx         ;Intel-syntax kommentar
mov eax, edx
.att_syntax prefix

Inline assembler

The GNU assembler is also distinguished from other assemblers by an inline syntax, which enables the assembler part to be effectively integrated into a high-level language part. This is done through a list of the input and output registers and the registers used in the assembler part. This allows the compiler to link an assembler part to the high-level language part during optimization without transfer overheads.

The above example as a C - inline assembler in Intel syntax :

  __asm__ __volatile__  (".intel_syntax noprefix \n\t"
      "pop edx         ;Intel-syntax kommentar \n\t"
      "mov eax, edx                            \n\t"
      ".att_syntax prefix                      \n\t"
      : /* no output operands  */
      : "d" (save_var), "a" (temp_var) /* inputs operands*/
      : "eax", "edx" /* intern verwendete register (clobber list)*/);


Web links

Wikibooks: Assembler programming for x86 processors  - learning and teaching materials

Individual evidence

  1. sourceware.org .
  2. ^ The GNU Assembler - Assembler Directives . Retrieved December 31, 2010.
  3. ^ Susan Welsh: AT&T Assembly Syntax . Sig 9, July 17, 2017, accessed November 13, 2019.
  4. AT&T Syntax versus Intel Syntax, accessed November 13, 2019.
  5. Ram Narayan: Linux assemblers: A comparison of GAS and NASM at IBMDeveloper on October 17, 2007, accessed on November 13, 2019.
  6. 5. Extended Asm. ( English ) www.ibiblio.org. March 1, 2003. Retrieved July 27, 2011: “ [...] we can also specify the operands. It allows us to specify the input registers, output registers and a list of clobbered registers "