FASM
Encyclopedia
FASM in computing
is an assembler. It supports programming in Intel-style
assembly language
on the IA-32
and x86-64
computer architectures. It claims high speed, size optimizations, operating system
(OS) portability, and macro abilities. It is a low-level
assembler and intentionally uses very few command-line options (see 'SSSO'). It is free and open source software
.
FASM contains bindings to the Windows GUI
and OpenGL
. All versions of FASM can directly output any of the following: flat "raw" binary
(usable also as DOS COM executable
or SYS driver), objects: Executable and Linkable Format
(ELF) or Common Object File Format
(COFF) (classic or MS-specific), or executables in either MZ, ELF, or Portable Executable
(PE) format (including WDM drivers, allows custom MZ DOS stub). Complex or obscure output file formats, such as OMF, New Executable
(NE), LE, and LX, are not natively supported by FASM (but see ObjConv). An unofficial port targeting the ARM architecture
(FASMARM) also exists.
. Its was released publicly in March 2000. FASM is completely written in assembly language
and comes with full source. It is self-hosting
and has been able to assemble itself since version 0.90 (May 4, 1999). It has been used to write several operating systems including MenuetOS
and DexOS.
. 32-bit support was added and then supplemented with optional DPMI support. It was written in a way that made it easy to port to any operating system that allowed flat 32-bit addressing; it was ported for Windows and then Linux.
FASM is a low-level assembler. It does not support as many high-level
statements as MASM or TASM
. It provides syntax features and macros which make it possible to customize or create missing statements. Its memory addressing syntax is similar to TASM's ideal mode and NASM. Brackets are used to denote memory operands as in both assemblers but their size is placed outside the brackets like in NASM.
FASM is a multi-pass assembler. It makes extensive code size optimization, and allows more forward referencing. A usual FASM construct is defining data or procedures only if they are used somewhere in the code, something that in most languages is done per-object by the linker.
FASM is based on the SSSO principle (same source, same output): the contents of the resulting file are not affected by the command line. Such an approach saves FASM sources from compiling problems often present in many assembly projects. On the other hand, it makes it very hard to maintain a project that consists of multiple separately compiled source files, or mixed-language projects. However, the Win32 FA.EXE wrapper
mitigates this somewhat. FASM projects can be built from one source file directly into an executable file without a linking stage.
Several compilers use FASM as a backend:
Computing
Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology...
is an assembler. It supports programming in Intel-style
X86 assembly language
x86 assembly language is a family of backward-compatible assembly languages, which provide some level of compatibility all the way back to the Intel 8008. x86 assembly languages are used to produce object code for the x86 class of processors, which includes Intel's Core series and AMD's Phenom and...
assembly language
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...
on the IA-32
IA-32
IA-32 , also known as x86-32, i386 or x86, is the CISC instruction-set architecture of Intel's most commercially successful microprocessors, and was first implemented in the Intel 80386 as a 32-bit extension of x86 architecture...
and x86-64
X86-64
x86-64 is an extension of the x86 instruction set. It supports vastly larger virtual and physical address spaces than are possible on x86, thereby allowing programmers to conveniently work with much larger data sets. x86-64 also provides 64-bit general purpose registers and numerous other...
computer architectures. It claims high speed, size optimizations, operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...
(OS) portability, and macro abilities. It is a low-level
Low-level programming language
In computer science, a low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture. Generally this refers to either machine code or assembly language...
assembler and intentionally uses very few command-line options (see 'SSSO'). It is free and open source software
Free and open source software
Free and open-source software or free/libre/open-source software is software that is liberally licensed to grant users the right to use, study, change, and improve its design through the availability of its source code...
.
FASM contains bindings to the Windows GUI
Gui
Gui or guee is a generic term to refer to grilled dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients. The term derives from the verb, "gupda" in Korean, which literally...
and OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...
. All versions of FASM can directly output any of the following: flat "raw" binary
Binary file
A binary file is a computer file which may contain any type of data, encoded in binary form for computer storage and processing purposes; for example, computer document files containing formatted text...
(usable also as DOS COM executable
COM file
In many computer operating systems, a COM file is a type of executable file; the name is derived from the file name extension .COM. Originally, the term stood for "Command file", a text file containing commands to be issued to the operating system , on many of the Digital Equipment Corporation mini...
or SYS driver), objects: Executable and Linkable Format
Executable and Linkable Format
In computing, the Executable and Linkable Format is a common standard file format for executables, object code, shared libraries, and core dumps. First published in the System V Application Binary Interface specification, and later in the Tool Interface Standard, it was quickly accepted among...
(ELF) or Common Object File Format
COFF
The Common Object File Format is a specification of a format for executable, object code, and shared library computer files used on Unix systems...
(COFF) (classic or MS-specific), or executables in either MZ, ELF, or Portable Executable
Portable Executable
The Portable Executable format is a file format for executables, object code and DLLs, used in 32-bit and 64-bit versions of Windows operating systems. The term "portable" refers to the format's versatility in numerous environments of operating system software architecture...
(PE) format (including WDM drivers, allows custom MZ DOS stub). Complex or obscure output file formats, such as OMF, New Executable
New Executable
The New Executable is a 16-bit .exe file format, a successor to the DOS MZ executable format. It was used in a special version of MS-DOS, Windows 1.0, Windows 2.x, and Windows 3.x...
(NE), LE, and LX, are not natively supported by FASM (but see ObjConv). An unofficial port targeting the ARM architecture
ARM architecture
ARM is a 32-bit reduced instruction set computer instruction set architecture developed by ARM Holdings. It was named the Advanced RISC Machine, and before that, the Acorn RISC Machine. The ARM architecture is the most widely used 32-bit ISA in numbers produced...
(FASMARM) also exists.
History
The project was started in 1999 by Tomasz Grysztar, a.k.a. Privalov, at that time, an undergraduate student of mathematics from PolandPoland
Poland , officially the Republic of Poland , is a country in Central Europe bordered by Germany to the west; the Czech Republic and Slovakia to the south; Ukraine, Belarus and Lithuania to the east; and the Baltic Sea and Kaliningrad Oblast, a Russian exclave, to the north...
. Its was released publicly in March 2000. FASM is completely written in assembly language
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...
and comes with full source. It is self-hosting
Self-hosting
The term self-hosting was coined to refer to the use of a computer program as part of the toolchain or operating system that produces new versions of that same program—for example, a compiler that can compile its own source code. Self-hosting software is commonplace on personal computers and larger...
and has been able to assemble itself since version 0.90 (May 4, 1999). It has been used to write several operating systems including MenuetOS
MenuetOS
MenuetOS is an operating system with a monolithic preemptive, real-time kernel, including video drivers, all written in FASM assembly language, for 64-bit and 32-bit x86 architecture computers, by Ville M. Turjanmaa...
and DexOS.
Design
FASM originally only ran in 16-bit flat real modeUnreal mode
In x86 computing, unreal mode, also big real mode, huge real mode, or flat real mode, is a variant of real mode , in which one or more data segment registers have been loaded with 32-bit addresses and limits. Contrary to its name, it is not a separate addressing mode that the x86-32 and x86-64...
. 32-bit support was added and then supplemented with optional DPMI support. It was written in a way that made it easy to port to any operating system that allowed flat 32-bit addressing; it was ported for Windows and then Linux.
FASM is a low-level assembler. It does not support as many high-level
High-level assembler
High-level assemblers in computing are assemblers for assembly language that incorporate features found in high-level programming languages.Some high-level assemblers are Borland's TASM, Microsoft's MASM, IBM's HLASM , Alessandro Ghignola's Linoleum, and Niklaus Wirth's PL/360.High-level assemblers...
statements as MASM or TASM
Tasm
TASM can refer to:*Turbo Assembler, Borland's x86 assembler* Turbo Assembler, Omikron's Commodore 64-based 6502 assembler*Table Assembler, a table driven cross-assembler for small microprocessors.*Tomahawk Anti-Ship Missile...
. It provides syntax features and macros which make it possible to customize or create missing statements. Its memory addressing syntax is similar to TASM's ideal mode and NASM. Brackets are used to denote memory operands as in both assemblers but their size is placed outside the brackets like in NASM.
FASM is a multi-pass assembler. It makes extensive code size optimization, and allows more forward referencing. A usual FASM construct is defining data or procedures only if they are used somewhere in the code, something that in most languages is done per-object by the linker.
FASM is based on the SSSO principle (same source, same output): the contents of the resulting file are not affected by the command line. Such an approach saves FASM sources from compiling problems often present in many assembly projects. On the other hand, it makes it very hard to maintain a project that consists of multiple separately compiled source files, or mixed-language projects. However, the Win32 FA.EXE wrapper
Wrapper
Wrapper generally refers to a type of packaging, such as a flat sheet made out of paper, cellophane or plastic to enclose an object.Wrapper may also refer to:* Wrapper , a woman's garment which is worn over nightwear or lingerie...
mitigates this somewhat. FASM projects can be built from one source file directly into an executable file without a linking stage.
Examples
- DexOS, BOS – 32-bit32-bitThe range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....
DOS-like OSes - Derrick Operating System – A 32-bit protected mode OS
- MenuetOSMenuetOSMenuetOS is an operating system with a monolithic preemptive, real-time kernel, including video drivers, all written in FASM assembly language, for 64-bit and 32-bit x86 architecture computers, by Ville M. Turjanmaa...
– 32- and 64-bit64-bit64-bit is a word size that defines certain classes of computer architecture, buses, memory and CPUs, and by extension the software that runs on them. 64-bit CPUs have existed in supercomputers since the 1970s and in RISC-based workstations and servers since the early 1990s...
GUI operating systems - MiraculixMiraculixMiraculix is a 32-bit operating system that originated from Russia.-History:The first version of this system was published in 2003, and named "UCS" . Created using a C++-like language, UCS had its own file system and provided interaction through a single-user console.In 2004, the second edition of...
– 32-bit GUI operating systems - PROE – x86-64 encryption engine
- RevaForth
- uFMOD – .xm player for Win32, Linux, Unix/BSD and KolibriOSKolibriOSKolibri or KolibriOS is a small open source x86 operating system written completely in assembly.It was forked off from MenuetOS.-System requirements:* i586 compatible CPU required* 8 MB of RAM* Boots from several devices; NTFS is also supported...
- +4_forever? – Commodore +4 Emulator
Several compilers use FASM as a backend:
- PureBasicPureBasicPureBasic is a commercially distributed procedural computer programming language and integrated development environment based on BASIC and developed by Fantaisie Software for Windows 32/64-bit, Linux 32/64-bit, and Mac OS X. An Amiga version is available, although it has been discontinued and...
- High Level AssemblyHigh Level AssemblyHigh Level Assembler is an assembly language developed by Randall Hyde. It allows the use of higher-level language constructs to aid both beginners and advanced assembly developers. It fully supports advanced data types and object-oriented assembly language programming...
(HLA) - BlitzMax
- Context/Win32
- B0
- :R4
External links
- FASM project: , official manual, examples, message board, archive of older versions
- [irc://irc.freenode.net/flatassembler #flatassembler] – IRC channel
- FASMARM – FASM for ARM processors, v1.24,
- FASMLIB 0.8.0 – portable 32-bit x86 asm lib for FASM/MASM/YASM/NASM/GASM