GNU Assembler

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

The executable file for the GNU assembler is named after the Unix assembler (as) named. GAS is platform-independent, and thus assemblierfähig for a large number of different computer architectures both run - as. GAS is released under the GNU General Public License v3 and is free software.

Generally valid syntax

The GNU assembler has a general syntax for all supported architectures. This syntax includes assembler directives and methods to comment.

Assembler directives

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

Comments

GAS uses by default the # character for a single line comment.

Example:

Pop % edx # this is a comment # This also

Movl % edx, % eax

Criticism

One source of criticism of the GAS is that it uses the AT & T assembler syntax for the x86 and x86-64 architectures, instead of the more common Intel syntax. Since version 2.10, however, GAS supports Intel syntax of the directive. Intel_syntax.

The above example in Intel syntax:

. intel_syntax NoPrefix pop edx; Intel syntax comment mov eax, edx. att_syntax prefix inline assembler

The GNU assembler distinguishes itself from other assemblers also by an in-line syntax, which makes it possible to effectively integrate the assembler part in a high voice part. This is accomplished by a list of input, output register and the registers used in the assembler part. This allows the compiler to connect an assembler part during optimization without passing overhead on the part of high-level language.

The above example as C inline assembler in Intel syntax:

__asm__ __ volatile__ ( ". intel_syntax NoPrefix \ n \ t"        "pop edx; Intel - syntax- comment \ n \ t"        "mov eax, edx \ n \ t"        ". att_syntax prefix \ n \ t"       : / * No output operands * /        " D" ( save_var ) "a" ( temp_var ) / * input operands * /       : " Eax ", " edx " / * used internally register ( clobber list) * / );

270177
de