Which assembler should I use?(x86)

From OSDev Wiki
Jump to: navigation, search



An assembler is a program, which converts assembly language code to machine code. Even if you are not using assembly language as your primary programming language for your OS, you will still have to write some of it. This article discusses advantages and disadvantages of the commonly recommended assemblers for OS development.

GNU as

GNU as, the assembler included in the GNU binutils, is the assembler that is tightly integrated in the GNU toolchain ( e.g. gcc) and therefore interacts best with it. It uses the AT&T syntax by default , though it can use some kind-of-intel syntax as well , it is commonly coupled with the C preprocessor to enable macro capabilities. GNU as can produce code for many different plattforms.


Nasm the netwide assembler, is a popular assembler using the intel syntax and an own macro system. It has been written in C , but only generates code for x86 and its predecessors.


The flat assembler, or fasm, is a self assembling assembler, written in Assembly language entirely and uses the intel-syntax with its own macro system. It only produces code for x86 and amd64 plattforms, though a fork for arm systems exists.


If you want to write your OS in C,C++ or another high level language you will need some minimal portion of Assembly language. In this case, the recommended assembler to use is the GNU as, as it integrates tightly with the GNU toolchain( that you are most likely to use) and, as it is included in the GNU binutils, does not introduce new dependencies to your project.

If you want to write an project in assembly language entirely, the latter two are usually the tools of choice, though especially for an OS the fact that fasm is self-assembling and only needs one dependency - a c standard library - to work gives it a slight advantage here, as it is way easier to port.

Personal tools