GAS

From OSDev.wiki
Jump to navigation Jump to search

GNU Assembler

[[Image:{{{image}}}|300px|]]
Website:http://www.gnu.org/software/binutils/

The GNU Assembler (GAS, executable named 'as') is part of the binutils package. If you are using GCC, you are also using gas - basically, GCC generates Assembler source which is turned into machine code by a subsequent (automatic) call to gas. Moreover, when you are using inline assembler in GCC code, you are also using gas.

Actually, gas is not one assembler, but a collection of assemblers - one for each of the platforms supported by GCC - which are very similar in their available options, their macro language etc.

Up until v2.10 of binutils, gas supported only AT&T syntax, which differs significantly from the Intel syntax used by virtually every other assembler. Today, gas supports both syntax sets (.intel_syntax and the default .att_syntax), and even allows disabling the otherwise mandatory operand prefixes '%' or '$' (..._syntax noprefix).

There are some pitfalls - several FP opcodes suffer from a reverse operand ordering that is bound to stay in there for compatibility reasons, .intel_syntax generates less optimized opcodes on occasion (try mov'ing to %si...). But if you can learn to live with them , gas provides you with a very solid and well-supported assembler that is fully integrated with the other GNU tools (like, implicit make rules, inline calling from C/C++ sources, and the ability to be called as gcc -o myfile.o myfile.s). GAS defaults to 32bit code, but can be switched to .code16. This requires some additional attention - you will want to check the documentation on that matter.

See Also

Articles

External Links