Which assembler should I use?(x86)

From OSDev Wiki
Jump to: navigation, search

Contents

Introduction

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 used assemblers for OS development.

GAS

The GNU Assembler, or GAS, is the assembler included in the GNU binutils. It is also the assembler that is tightly integrated in the GNU toolchain and therefore interacts best with it. GAS uses the AT&T syntax by default though it can use Intel syntax as well. It is commonly coupled with the C preprocessor to enable macro capabilities. GAS can produce code for many different platforms.

NASM

The Netwide Assember, or NASM, is a popular assembler using Intel syntax and an own macro system. It has been written in C but only generates code for x86 and its predecessors.

FASM

The Flat Assembler, or FASM, is a self assembling assembler written entirely in assembly language and uses Intel-syntax with its own macro system. It only produces code for ia32 and amd64 platforms, though a fork for ARM systems exists.

Conclusion

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 GAS as it integrates tightly with the GNU toolchain which is commonly used in OSDev. GAS is included in the GNU binutils and therefore 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. However, FASM being self-assembling and only needs a C standard library to work gives it a slight advantage here as it is way easier to port.

Personal tools
Namespaces
Variants
Actions
Navigation
About
Toolbox