Which assembler should I use?(x86): Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Created page with "== 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 la..."
 
m Add a link to the x86 assemblers comparison page.
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Introduction ==
== 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 recommended assemblers for OS development.
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.


== GNU as ==
== GAS ==
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.
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 ==
== NASM ==
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 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 ==
== FASM ==
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.
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. Its next generation, FASMG can generate almost for any architecture with its powerful macro system: x86, ARM, Z80 and even [[WebAssembly]].


== Conclusion ==
== 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 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 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, 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.
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.

See also [[Tool_Comparison#x86_Assemblers|x86 Assemblers Comparison]] for a comparison of features between different assemblers.

[[Category:Assemblers]]
[[Category:Assembly]]
[[Category:x86]]

Latest revision as of 19:31, 15 December 2023

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. Its next generation, FASMG can generate almost for any architecture with its powerful macro system: x86, ARM, Z80 and even WebAssembly.

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.

See also x86 Assemblers Comparison for a comparison of features between different assemblers.