X86 Assembly/x86 Assemblers
From Wikibooks, the open-content textbooks collection
There are a number of different assemblers available for x86 architectures. This page will list some of them, and will discuss where to get the assemblers, what they are good for, and where they are used the most.
Contents |
[edit] GNU Assembler (GAS)
The GNU assembler is most common as the assembly back-end to the GCC compiler. One of the most compelling reasons to learn to program GAS (as it is frequently abbreviated) is because inline assembly instructions in the GCC compiler need to be in GAS syntax. GAS uses the AT&T syntax for writing the assembly language, which some people claim is more complicated, but other people say it is more informative.
[edit] Microsoft Macro Assembler (MASM)
Microsoft's Macro Assembler, MASM, has been in constant production for many many years. Many people claim that MASM isn't being supported or improved anymore, but Microsoft denies this: MASM is maintained, but is currently in a bug-fixing mode. No new features are currently being added. However, Microsoft is shipping a 64-bit version of MASM with new 64-bit compiler suites. MASM can still be obtained from microsoft as either a download from MSDN, or as part of the Microsoft DDK. The currently available version of MASM is version 8.x.
MASM uses the Intel syntax for its instructions, which stands in stark contrast to the AT&T syntax used by the GAS assembler. Most notably, MASM instructions take their operands in reverse order from GAS. This one fact is perhaps the biggest stumbling block for people trying to transition between the two assemblers.
MASM also has a very powerful macro engine, which many programmers use to implement a high-level feel in MASM programs.
[edit] External Links
[edit] Netwide Assembler (NASM)
The Netwide Assembler, NASM, was started as an open-source initiative to create a free, retargetable assembler for 80x86 platforms. When the NASM project was started, MASM was still being sold by microsoft (MASM is currently free), and GAS contained very little error checking capability. GAS was, after all, the backend to GCC, and GCC always feeds GAS syntax-correct code. For this reason, GAS didn't need to interface with the user much, and therefore writing code for GAS was very tough.
NASM uses a syntax which is "similar to Intel's but less complex".
The NASM users manual is found at http://nasm.sourceforge.net/doc/html/nasmdoc1.html .
Features:
- Cross platform: Like Gas, this assembler runs on nearly every platform, supposedly even on PowerPC Macs (though the code generated will only run on an x86 platform)
- Open Source
- Macro language (code that writes code)
[edit] Flat Assembler (FASM)
Although it was written in assembly, it runs on several operating systems, including DOS, DexOS, Linux, Windows, and BSD. Its syntax is similar to TASM's "ideal mode" and NASM's but the macros in this assembler are done differently.
Features:
- Written in itself; and therefore its source code is an example of how to write in this assembler
- Clean NASM-like syntax
- Very very fast
- Has Macro language (code that writes code)
- Built-in IDE for DOS and Windows
- Creates binary, MZ, PE, ELF, COFF - no linker needed
[edit] External Links
[edit] YASM Assembler
YASM is a ground-up rewrite of NASM under the new BSD licence. YASM is designed to understand multiple syntaxes natively (NASM and GAS, currently). The primary focus of YASM is to produce "libyasm", a reusable library that can work with code at a low level, and can be easily integrated into other software projects.

