An assembler is a computer program for translating assembly language — essentially, a mnemonic representation of machine language — into object code. A cross assembler (see cross compiler) produces code for one processor, but runs on another.
As well as translating assembly instruction mnemonics into opcodes, assemblers provide the ability to use symbolic names for memory locations (saving tedious calculations and manually updating addresses when a program is slightly modified), and macro facilities for performing textual substitution — typically used to encode common short sequences of instructions to run inline instead of in a subroutine.
Assemblers are far simpler to write than compilers for high-level languages, and have been available since the 1950s. Modern assemblers, especially for RISC based architectures, such as MIPS, Sun SPARC and HP PA-RISC, optimize instruction scheduling to exploit the CPU pipeline efficiently. Most assemblers are 'macro assemblers', which allow complex macro constructs.
High-level assemblers provide high-level-language abstractions such as advanced control structures, high-level procedure/function declarations and invocations, and high-level abstract data types including structures/records, unions, classes, and sets.
Hundreds of assemblers have been written; some notable examples include:
- A56 - for Motorola DSP56000 DSPss (DSP56k series)
- FAP - for IBM 700/7000 series mainframes
- FASM - open source IA-32 assembler
- GAS (GNU Assembler) - open source, available for many architectures
- MACRO-11 - for DEC PDP-11
- MASM (Macro/MS Assembler) - x86 assembler from Microsoft
- NASM (Netwide Assembler) - open source x86 assembler
- PAL-III - for DEC PDP-8
- TASM (Turbo Assembler) - x86 assembler from Borland
In the futuristic research field of nanotechnology, an assembler is a construction machine that manipulates and builds with individual atoms or molecules. One of the prime goals of long-term nanotech research is the production of a programmable self-replicating assembler. This is a device which can make a complete copy of itself given raw materials and energy. After sufficient quantities of assemblers are available, they are then re-programmed to produce something else useful. In science fiction literature, such assemblers have been called matter compilers.
Nature abounds with nanotechnological self-replicating assemblers called bacteria, however they are not easily programmable. Some progress has been made in this area, where researchers have inserted genes for a particular protein into a bacterium. One of the first examples of this is the immune-system hormone interferon.