News Categories |
Main /
Devel Asm
On this page… (hide)
1. Syntax messFor x86 CPU’s, there exist multiple assembly syntaxes:
A comparison of assemblers supporting MASM syntax or similar can be (no longer) found at Japheth ’s JWASM page: japheth.de/JWasm.html . A comparison of INTEL syntax with GAS can be found at YASM project page: tortall.net/projects/yasm/wiki/GasSyntax . Assembly source code conversion tools:
2. Code assembler in what ?Most assemblers are coded in C , this brings some portability on the host side, OTOH is considered as “far away from acceptable” by some “hard-core” assembler freaks since not self-hosting, and relying on external tools like GCC needed to compile the assembler itself. Products coded in assembly are FASM, RosASM (very limited usefulness for DOS), SolASM (self-hosting, fact confirmed by author, but closed source), and possibly (closed source) LZASM. 3. Assembler AKA assembly compiler products3.1 MASM / MASM32MASM exists since 1981, and it is still maintained by Microsoft - not very frequently, but every now and then support for new CPU opcodes is implemented. Also, nowadays it is not being promoted as much as other Microsoft’s products - in fact not at all. MASM is not free, all the various versions available for legal download do have severe license restrictions. Most of old DOS code as well as code having old roots uses MASM syntax and is intended to be compiled with it, mostly prefers version 5.1 or 6.1xx - code written for 5.1 however might not compile with 6.1xx anymore. Versions 6.xx brought various syntax changes, and added support for high-level structures ( .if , .while , … ) into the compiler core. There are also later versions (7, 8 and 9), around, but they never became that popular as 5.1 and 6.1xx and were almost never used for DOS development. One source to get MASM is MASM32 (it includes MASM v6.14 ). However, MASM32 is a package for Win32 programming with MASM, it’s not intended for programming 32-bit (and even less 16-bit) DOS applications. Furthermore, MASM32 tries to prohibit by license to develop “Open Source” programs, as well as programs for non-MS systems! Paid versions of MASM don’t have such restrictions. Technically MASM itself supports compiling DOS code, 16-bit and 32-bit, of course. 16-bit code requires an OMF linker, alternatives to the original MASM linker (dropped and barred out from bundling with MASM long ago) are for example VALX (contained in CC386) or OPTLINK (contained in Digital Mars C++). MASM is written in C (closed source), versions 5.xx are compiled with Microsoft C compiler version 5 as real-mode DOS applications, MASM 6.xx are compiled with C compiler 6 as Win32-PE binaries, versions up to 6.11d however are stubbed with a version of PharLap DOS extender providing a minimal Win32 emulation, allowing to use them also in DOS as-is. Newer versions are no longer intended for use in DOS, but they still run using HX-DOS Extender. Download: http://website.masm32.com/microsft.htm
3.2 TASMTASM is - like MASM - rather old and not free. It supports 2 types of syntax: MASM-like (default) and IDEAL mode - later the latter one inspired the NASM and FASM syntax, and is used by LZASM (see below) as well. Was also used frequently for DOS development, alone or mixed with PASCAL or C language. One famous project with nice TASM source is the DOS/32A extender. Historical note: FASM started on TASM before it became self-compiling. 3.3 Paradigm ASMClone of TASM supporting both MASM and IDEAL MODE syntax. Product itself not very useful, commercial, designed for “embedded” stuff, has a manual called pasmug.pdf being “offered” as manual for LZASM (see below), or Google for it. Company page: http://www.devtools.com/pcpp/assembler.htm . 3.4 PoASMRelated to Pelles C compiler. After extracting it from the installer (no way in DOS), it can run in DOS also using HX-DOS . It has a syntax comparable with MASM, but in many cases it can’t be used as a replacement, because it doesn’t support generating 16-bit code or segmented memory models. Furthermore, support for macros is limited and differs significantly from MASM. Supports only COFF output format. It has been premature, and now can be considered as obsolete in favor of JWASM. 3.5 JWasmJWasm is intended to be a Masm compatible assembler, it can be used as a drop-in replacement for Masm. Unlike current versions of Masm, the JWasm license doesn’t restrict the usage to certain OS’es. Binaries for DOS (32-bit and 16-bit), Windows and Linux are available. Also, JWasm is open source, it’s a fork of Open Watcom’s WASM. Currently 16, 32 and 64 bit code generation is supported, formatted as OMF, COFF, ELF, MZ EXE or raw binary. Instructions up to SSSE3 (Intel Core 2) are supported. The 16-bit DOS version has some limitations (no 64-bit support, no COFF and ELF, no latest SSSE instructions, limited size of source code that can be compiled). Work on JWasm started in 2008-March (also some experimental releases), versions published so far are:
3.6 WASM.EXE (WATCOM-ASM)Original WASM was created for WATCOM compiler long ago, in recent years WASM came with OpenWATCOM C compiler versions 1.0 to 1.7, uses MASM syntax, “intended” to be fully MASM 6.xx compatible, but has been premature and limited, and developing slowly, and providing a “mess-compatibility” with something between MASM 5.1 and 6.xx only, well usable for “additional” ASM files for C projects (like MP3 decoder of MPXPLAY), but not for “serious” ASM development. The WASM source code has been the root for JWasm, see above. However recently there was some partially independent development of “original WASM” as well and support for TASM (both MASM and IDEAL mode, but only partial) was added in version 1.9, while JWasm doesn’t support IDEAL mode or special TASM compatibility. Project page: openwatcom.org/index.php/Wasm WASM in OpenWATCOM Wiki 3.7 NASM“The Netwide Assembler” Written in pretty well portable C language (prefers GCC (DGJPP for DOS) compiler, but old versions also have a 16-bit DOS version (old Boreland C compiler ?), provides sort of portability - develop for I80×86 CPU on other CPU’s, for running your code you will need additionally a full emulator then ;-) NASM can output 16-bit, 32-bit and 64-bit (2.xx versions, not very useful dor DOS) code formatted as plain binary (useful to create DOS .COM and .SYS files) or various object formats, including OMF (usual .OBJ files) and COFF . Project started in 1996 (?), was under intensive development until 2002, then slow development until 2005 (YASM (see below) fork created in this time, 2005 version 0.98.39 came out), since 2007 fast development again (0.99 and 2.xx versions, 64-bit support). For years the license was LGPL, with version 2.07 (2009-Jul) it was changed to the 2-clause BSD license. Major developers and contributors: Simon Tatham, Julian Hall, H. Peter Anvin, Frank B. Kotler, Victor van den Elzen, Cyrill Gorcunov. Some relevant versions:
Project pages (hint: open link in a new window):
Download (hint: open link in a new window):
Project includes a disassembler, NDISASM , as well as a good (non-MASM style, up-to-date) instruction list, the preceding statements about “MS-DOS” are however no longer acceptable. 3.8 YASM
Version 1.0 released 2010-Apr-08, so far latest 1.2.0 2011-Oct-31. Based originally on NASM, rewrite and drop-in replacement (except OMF support), later additional syntax support added, BSD licensed. DUGL ASM code (closed) changed from NASM to YASM recently. Written in C , DOS version compiles with DGJPP. Features:
Lacks:
3.9 FASM = FlatAssembler
Project page: http://flatassembler.net Latest version: 1.71.54 from 2016-Jun-09 AboutBy Tomasz Grysztar , self-compiling/self-hosting, liberal BSD-like open source license. FASM can generate 16-bit and 32-bit code (+ 64-bit) and easily mix them. A good 32-bit DOS version is available (at least 80386 CPU is required, no 16-bit version exists). FASM’s syntax is inspired by TASM’s “ideal” mode and NASM, with further updates which are rather unique to it. So far FASM has been most famous for usage in development of some OS’es like MenuetOS (64-bit and 32-bit GUI), DexOS and BOS (latter 2 are 32-bit DOS-like systems). FASM FeaturesFASM supports various output formats:
FASM is efficient and easy to use, the compiler resides in one single file of cca 100 KiB size (!). FASM provides a powerful preprocessing and macro system, although it’s “original” and not compatible with other assemblers. FASM includes an expression evaluator with 65-bit (sixty-five!) precision (since version 1.70, actually 1.69.41beta). There are almost no commandline options: SSSO - same source, same output , makefiles/linking not needed but also possible if someone really wants to (still no OMF). FASM’s DOS version is sort of “strange” - runs in unreal mode if available (not with EMM386 or if CPU seems not to support “this” unreal mode), otherwise uses DPMI (host must be active). Even “worse”, it uses a “32-bit” unreal mode, an approach which is rather unique, but also very interesting from a technical point of view. FASM also has a one file DOS IDE version: text editor with syntax highlighting, calculator, built-in compiler, no mouse support. FASM Cons
FASM HistoryFirst public version was released 2000/03/15 (???), first selfcompilable one was 0.90 1999/05/04, and was previously developed on Tomasz ’s previous non-public assembler ASM32 (32-bit DOS only), and “finally” ASM32 had started on TASM. FASM GIn 2015 Tomasz started a development stage of FASM that might look a bit crazy at first glance: removing support of all instructions and output formats, leaving behind only preprocessor and expression evaluator. What’s the point of that? Well, adding support for other CPU’s than Intel. There have been hacky derivatives of FASM for other target CPU’s around for years, and this move is supposed to provide a well designed method to achieve the objective. This approach is implemented in a separate branch of FASM called FASM G, the good old (or less good, if you don’t appreciate the huge amount of the latest Intel instructions having been and being added) FASM is not abandoned or deleted, but will probably develop slower in future. 3.10 LZASMBy Stepan Polovnikov , closed source freeware, DOS and Win32 versions. Lazy Assembler latest version: 0.56 (06 AUG 2007) . Is - mostly - compatible with TASM IDEAL mode.
3.11 Solar Assembler (SOLASM)By Bogdan Ontanu , closed source, free for personal use (see license). There are binaries for SolarOS, MacOS, Win32 & Linux available. To run the assembler in DOS you’ll need the Win32 version and HXRT. SolAsm’s syntax is - like FASM and LZASM - inspired by TASM. Has output support for 16, 32 and 64 bit code, raw binary, object formats OMF, COFF and ELF and direct PE format (EXE or DLL). Project page: oby.ro/sol_asm/index.html . 3.12 DJASMThis one, itself written in C, is considered being sort of half-baked and not a serious development tool, since it was created “only” to compile the DGJPP “stub”: 14 KiB source to 2 KiB binary. Very little code, but valuable info about DPMI usage. 3.13 GAS (GNU Assembler, AS.EXE)Very popular, although not very good. Why ? It is the assembler used by GCC (3 stage compilation: C/C++/HLL → ASM, ASM → objects, finally linking) and therefore all compilers based on it (DGJPP, MinGW/CYGWIN, FreePASCAL, FreeBASIC). It introduced the so called “AT&T” syntax (source operand first, then destination, plus many other “extraordinary” rules), but supports also the “Intel” one (destination operand first, then source) for quite a long time. In this mode it mostly removes the “AT&T” oddnesses, and accepts a syntax acceptably similar to TASM IDEAL or FASM (still some PTR’s are required). The second flaw is its lack of correctness (expects GCC to feed in correct code) - many bugs detectable (and detected by other assemblers) during compilation are silently passed and compiled into bad code - disassemble or debug to find them. Finally, it occupies cca 1/2 to 1 MiB (various versions and builds of them do exist) what is quite big - FASM has 100 KiB only and offers more features. 2 famous projects compiling with GAS are UPX (most of it is C++, a part is ASM using “Intel” syntax of GAS) and the Loonix kernel (most of it is C, a part is ASM using the “AT&T” syntax). Source files for GAS can have the extension .S (usually when using “AT&T” syntax) , or .ASM (mostly when using INTEL syntax) . FreeBASIC “libraries” use both (besides dominating C language) . 3.14 Misc / others
4. Linkers4.1 VALX16 and 32 bit OMF linker, by David Lindauer / Ladsoft , open source (GPL), based on old VAL linker, available with CC386 compiler (no longer separately).
4.2 WALK32 / W32LinkDOS hosted (8086 !!!) “cross” OMF linker with Win32 PE output (only), some other related tools (but no assembler) included, hosted at programmersheaven.com/download/355/download.aspx . 4.3 Open WATCOM WLINK , JWLINK16 and 32 bit OMF and COFF linker, part of Open WATCOM project. Japheth writes about MZ support: “has improved recently, since v1.6 it can handle 32bit object modules. Since v1.8 it also accepts 32bit segments and DGROUP with size > 64 kB.” Nevertheless he maintains a JWLINK fork with some fixes and enhancements in output formats MZ EXE and PE , it is used for creation of some HX binaries.
4.4 PO-LINK32 and 64-bit COFF to PE linker, comes with Pelles C package, closed source freeware.
4.5 Digital Mars OPTLINKIncluded in the Digital Mars C++ package. FreeWare. Fast.
4.6 LD32 and 64-bit COFF linker, designed for GCC, part of GNU project, used by DJGPP, FreeBASIC and FreePASCAL (where it recently became optional only because of “internal” linker ?).
4.7 ObjConvAlso “sort-of” a linker. Allows to convert various 32-bit and 64-bit object formats (most useful for DOS: COFF32 < - > OMF32) and disassemble (smart(!), but slow on big files) object files and PE into MASM or NASM syntax, minimal “read-only” OMF16 support. By Agner Fog , C++ , open source, GPL. Author provides (besides source code) a Win32 console binary only, a native DOS binary is provided by Japheth at his JWasm page, see above. 5. See also
|
Recent Comments