The Yasm Modular Assembler Project
Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes, outputs binary, ELF32, ELF64, 32 and 64-bit Mach-O, RDOFF2, COFF, Win32, and Win64 object formats, and generates source debugging information in STABS, DWARF 2, and CodeView 8 formats.
Key Current User-Visible Features
- Nearly feature-complete lexing and parsing of NASM syntax.
- Basic support for TASM syntax.
- Nearly feature-complete lexing and parsing of GAS (GNU assembler) syntax.
- AMD64 support (enabled using “BITS 64”, “-m amd64”, or selecting an explicitly 64-bit object format output such as “-f win64” or “-f elf64”)
- 64-bit (and larger) integer constants allowed (including math operations).
- A fast jump size optimizer equivalent to or better than other assemblers’ multi-pass optimizers.
- Support for multiple object formats:
- STABS, DWARF2, and CodeView debug formats.
- Portability; currently compilable on:
- Internationalization support via GNU gettext.
Key Internal Features
The core focus of Yasm is not the yasm commandline frontend; rather, it is the Libyasm library and associated loadable modules (see the programmer references for documentation). Libyasm and the modules are intended for reuse in other sorts of programs dealing with code at the assembly level (compilers, debuggers, etc). Someday, libyasm may be packaged separately from the rest of Yasm.
A NASM syntax and GAS syntax recursive-descent parser.
Architecture-specific instruction parsers hand-written for simplicity and size, as well as to make it easy to add additional architectures while retaining the same front-end syntax. The blend of recursive descent for syntax and a hand-written parser for instructions strikes a great balance between the strengths and weaknesses of each approach.
A NASM syntax lexer written in re2c. A highly efficient scanner generator (almost always faster than lex/flex), it’s also very embeddable due to its code generation methodology, allowing a number of re2c scanners to be used in various places in yasm without any worries about naming conflicts.
A GAS syntax lexer written in re2c.
Many of the modular interfaces at least superficially finished. This is still an area that needs a lot of work.
A decent (and growing) set of assembler test input files to test the entire assembler as well as specific modules.