Microsoft Macro Assembler

Last updated
Microsoft Macro Assembler
Developer(s) Microsoft
Initial release1981;42 years ago (1981)
Stable release
14.16.27023.1 / March 7, 2017;6 years ago (2017-03-07)
Operating system Microsoft Windows and MS-DOS
Type Assembler
License Commercial proprietary software
Website docs.microsoft.com/en-us/cpp/assembler/masm/microsoft-macro-assembler-reference

The Microsoft Macro Assembler (MASM) is an x86 assembler that uses the Intel syntax for MS-DOS and Microsoft Windows. Beginning with MASM 8.0, there are two versions of the assembler: One for 16-bit & 32-bit assembly sources, and another (ML64) for 64-bit sources only.

Contents

MASM is maintained by Microsoft, but since version 6.12 it has not been sold as a separate product. It is instead supplied with various Microsoft SDKs and C compilers. Recent versions of MASM are included with Microsoft Visual Studio.

Notable applications compiled using MASM are RollerCoaster Tycoon which was 99% written in assembly and built with MASM. [1]

History

The earliest versions of MASM date back to 1981. [2] They were sold either as the generic "Microsoft Macro Assembler" for all x86 machines or as the OEM version specifically for IBM PCs. By Version 4.0, the IBM release was dropped. Up to Version 3.0, MASM was also bundled with a smaller companion assembler, ASM.EXE. This was intended for PCs with only 64k of memory and lacked some features of the full MASM, such as the ability to use code macros.

MS-DOS versions up to 4.x included Microsoft's LINK utility, which was designed to convert intermediate OBJ files generated by MASM and other compilers; however, as users who did not program had no use of the utility, it was moved to their compiler packages.

Version 4.0, released October 1985, added support for 286 instructions.

Version 5.0, released August 1987, supported 386 instructions, and also shorthand mnemonics for segment descriptors (.code, .data, etc.), but it could still only generate real mode executables.

Through version 5.0, MASM was available as an MS-DOS application only. Versions 5.1 and 6.0 were available as both MS-DOS and OS/2 applications. [3]

Version 6.0, released in 1991, added parameter passing with "invoke" and some other high level-like constructs, in addition to the already existing high level-like records, among other things. Both 6.0 and 6.0B were able to be run on an 8086 processor but could generate flat 32 bit 386 code. In 1992, 6.1 was released, which added support for the COFF object format used by Windows NT, and removed support for OS/2. 6.1 was built as a bi-modal binary before the Win32 API was finalized, and is incompatible with running on Windows NT due to missing exports. [4]

In 1993 full support for protected mode 32-bit applications and the Pentium instruction set was added. The 6.11 MASM binary at that time (1993) was shipped as a "bi-modal" (win32, i.e. PE) DOS-extended binary (using the Phar Lap TNT DOS extender). However, the setup.exe is an MZ executable so won't run under 64-bit versions of Windows, and the bi-modal ml.exe is compressed, and the decomp.exe is an NE executable, so also won't run under 64-bit versions of Windows (if you were hoping to manually extract the required ml.exe and ml.err), so you effectively need access to 32-bit Windows (or MSDOS) in order to install it. Version 6.11 is the last version of MASM that will run under MS-DOS. There were a series of patches available, up to 6.11d, that need 32-bit Windows to run, but the patched ml.exe still has the Phar Lap dos extender so can still be run under MSDOS.

Versions 6.12 to 6.14 were implemented as patches for version 6.11. These patches were self-extracting PK executables (i.e. MSDOS), so won't run under 64-bit Windows. Even if you extract them by other means, the patch.exe is an NE executable so won't be able to run on 64-bit Windows to update ml.exe either. If you do run on a 32-bit Windows (or earlier), patch will strip the Phar Lap dos extender from ml.exe so it can no longer be run on MSDOS. The stripping of Phar Lap makes the MZ portion of the executable smaller, so that the "PE" signature is more easily visible, unlike the situation with 6.11 where the PE signature was a long way into the file.

By the end of 1997, MASM fully supported Windows 95 and included some AMD-specific instructions. [5]

In 1999, Intel released macros for SIMD and MMX instructions, which were shortly thereafter supported natively by MASM. With the 6.15 release in 2000, Microsoft discontinued support for MASM as a separate product, instead subsuming it into the Visual Studio toolset. Though it was still compatible with Windows 98, current versions of Visual Studio were not. [5] Support for 64-bit processors was not added until the release of Visual Studio 2005, with MASM 8.0.

After 25 June 2015, there are at least three different MASMs with the version number 14.00.23026. In Microsoft Visual Studio 2015 Enterprise Edition, there is one "amd64_x86" ml and two ml64s, "x86_amd64" and "amd64". They run on different platforms targeting different platforms:

Object module formats supported by MASM

Early versions of MASM generated object modules using the OMF format, which was used to create binaries for MS-DOS or OS/2.

Since version 6.1, MASM is able to produce object modules in the Portable Executable [6] [7] (PE/COFF) format. PE/COFF is compatible with recent Microsoft C compilers, and object modules produced by either MASM or the C compiler can be routinely intermixed and linked into Win32 and Win64 binaries.

Assemblers compatible with MASM

Some other assemblers can assemble most code written for MASM, with the exception of more complex macros.

Mixed language programming support

Documentation for 1987's version 5.1 included support for "Microsoft BASIC, C, FORTRAN, Pascal." [8]

See also

Related Research Articles

<span class="mw-page-title-main">Netwide Assembler</span> Assembler for the Intel x86 architecture

The Netwide Assembler (NASM) is an assembler and disassembler for the Intel x86 architecture. It can be used to write 16-bit, 32-bit (IA-32) and 64-bit (x86-64) programs. It is considered one of the most popular assemblers for Linux and x86 chips.

The Portable Executable (PE) format is a file format for executables, object code, DLLs and others used in 32-bit and 64-bit versions of Windows operating systems. The PE format is a data structure that encapsulates the information necessary for the Windows OS loader to manage the wrapped executable code. This includes dynamic library references for linking, API export and import tables, resource management data and thread-local storage (TLS) data. On NT operating systems, the PE format is used for EXE, DLL, SYS, MUI and other file types. The Unified Extensible Firmware Interface (UEFI) specification states that PE is the standard executable format in EFI environments.

<span class="mw-page-title-main">Windows API</span> Microsofts core set of application programming interfaces on Windows

The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations that are often referred to by their own names. Almost all Windows programs interact with the Windows API. On the Windows NT line of operating systems, a small number use the Native API.

<span class="mw-page-title-main">FASM</span> Open source assembler for x86 processors

FASM is an assembler for x86 processors. It supports 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. It is free and open-source software.

x86-64 Type of instruction set developed by AMD

x86-64 is a 64-bit version of the x86 instruction set, first announced in 1999. It introduced two new modes of operation, 64-bit mode and compatibility mode, along with a new 4-level paging mode.

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a PC but generates code that runs on an Android smartphone is a cross compiler.

<span class="mw-page-title-main">DJGPP</span> Implementation of the GNU toolchain for DOS

DJ's GNU Programming Platform (DJGPP) is a software development suite for Intel 80386-level and above, IBM PC compatibles which supports DOS operating systems. It is guided by DJ Delorie, who began the project in 1989. It is a port of the GNU Compiler Collection (GCC), and mostly GNU utilities such as Bash, find, tar, ls, GAWK, sed, and ld to DOS Protected Mode Interface (DPMI). Supported languages include C, C++, Objective-C/C++, Ada, Fortran, and Pascal.

.exe is a common filename extension denoting an executable file for Microsoft Windows, OS/2, and DOS.

<span class="mw-page-title-main">COM file</span> Type of simple executable file

A COM file is a type of simple executable file. On the Digital Equipment Corporation (DEC) VAX operating systems of the 1970s, .COM was used as a filename extension for text files containing commands to be issued to the operating system. With the introduction of Digital Research's CP/M, the type of files commonly associated with COM extension changed to that of executable files. This convention was later carried over to DOS. Even when complemented by the more general EXE file format for executables, the compact COM files remained viable and frequently used under DOS.

High Level Assembly (HLA) is a language developed by Randall Hyde that 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 programming. It uses a syntax loosely based on several high-level programming languages (HLLs), such as Pascal, Ada, Modula-2, and C++, to allow the creation of readable assembly language programs, and to allow HLL programmers to learn HLA as fast as possible.

Turbo Assembler is an assembler for software development published by Borland in 1989. It runs on and produces code for 16- or 32-bit x86 MS-DOS and compatible on Microsoft Windows. It can be used with Borland's other language products: Turbo Pascal, Turbo Basic, Turbo C, and Turbo C++. The Turbo Assembler package is bundled with Turbo Linker and is interoperable with Turbo Debugger.

Virtual DOS machines (VDM) refer to a technology that allows running 16-bit/32-bit DOS and 16-bit Windows programs when there is already another operating system running and controlling the hardware.

<span class="mw-page-title-main">Phar Lap Software</span> Software company

Phar Lap Software, Inc., was a software company specializing in software development tools for DOS operating systems. The company was named after the champion New Zealand racehorse Phar Lap. They were most noted for their software allowing developers to access memory beyond the 640 KiB limit of DOS and were an author of the VCPI standard.

The DOS MZ executable format is the executable file format used for .EXE files in DOS.

In computer security, executable-space protection marks memory regions as non-executable, such that an attempt to execute machine code in these regions will cause an exception. It makes use of hardware features such as the NX bit, or in some cases software emulation of those features. However, technologies that emulate or supply an NX bit will usually impose a measurable overhead while using a hardware-supplied NX bit imposes no measurable overhead.

A86 is an assembler for MS-DOS which generates code for the Intel x86 family of microprocessors. Written by Eric Isaacson, it was first made available as shareware in June 1986. The assembler is contained in one 32K executable and can directly produce a COM file or an object file for use with a standard linker. It comes with a debugger, D86.

Computer hardware or software is said to be bug compatible if it exactly replicates even an undesirable feature of a previous version. The phrase is found in the Jargon File.

Open Watcom Assembler or WASM is an x86 assembler produced by Watcom, based on the Watcom Assembler found in Watcom C/C++ compiler and Watcom FORTRAN 77. Further development is being done on the 32- and 64-bit JWASM project, which more closely matches the syntax of Microsoft's assembler.

The command-line tool exe2bin is a post-compilation utility program available on MS-DOS and other operating systems.

<span class="mw-page-title-main">MS-DOS 7</span> Version of MS-DOS operating system

MS-DOS 7 is a real mode operating system for IBM PC compatibles. Unlike earlier versions of MS-DOS it was not released separately by Microsoft, but included in the Windows 9x family of operating systems. Windows 95 RTM report it as MS-DOS 7.0, while Windows 95 OSR 2.x and Windows 98 report as 7.1. The real-mode MS-DOS 7.x operating system is contained in the IO.SYS file.

References

  1. "Chris Sawyer Software Development". www.chrissawyergames.com. Retrieved 2023-01-05.
  2. Watt, Peggy; Christine McGeever (January 7, 1985). "Macintosh Vs. IBM PC At One Year". InfoWorld. Vol. 7, no. 1. pp. 15–16. ISSN   0199-6649. The IBM PC Macro Assembler was released in December 1981.
  3. Marshall, Martin (April 29, 1991). "Macro Assembler Update Adds High-Level Features". InfoWorld. Vol. 13, no. 17. p. 21. ISSN   0199-6649.
  4. "Q94314: 32-Bit Flat Memory Model MASM Code for Windows NT". Archived from the original on 13 January 2021. Retrieved 3 October 2023.
  5. 1 2 R. E. Harvey (2007). "Assemblers". Archived from the original on 16 February 2008. Retrieved 4 February 2010.
  6. "Archived copy". Archived from the original on 2009-01-26. Retrieved 2008-06-24.{{cite web}}: CS1 maint: archived copy as title (link)
  7. "WHDC White Papers and Documentation". Microsoft . Retrieved 25 September 2016.
  8. Microsoft Macro Assembler 5.1, Mixed-Language Programming Guide. p. 3.