Developer(s) | Microsoft |
---|---|
Stable release | 10.0.30319.1 / April 12, 2010; 18 months ago |
Operating system | Microsoft Windows and MS-DOS |
Type | Assembler |
License | Microsoft EULA |
The Microsoft Macro Assembler is an x86 assembler that uses the Intel syntax for Microsoft Windows. As of 2011 there was a version of the Microsoft Macro Assembler for 16-bit and 32-bit assembly sources, MASM, and a different one, ML64, for 64-bit sources only. References below to MASM include ML64 where appropriate.
- In this tutorial I will show you how to install MASM. MASM is a component of Microsoft Visual Studio toolset, so we'll need to download and install it.
- In this tutorial I will show you how to install MASM. MASM is a component of Microsoft Visual Studio toolset, so we'll need to download and install it.
MASM is maintained by Microsoft, but since version 6.12 has not been sold as a separate product, but supplied with various Microsoft SDKs and C compilers. As of 2011 MASM 8.0 was available free of charge for download from Microsoft for non-commercial use only[1]. It will only install if Visual C++ 2005 Express, also downloadable without charge, is already installed.
MASMのディスカッション・フォーラムもある。 WinAsm Studio IDE - アセンブリ・フォーラム、オープンソフト・プロジェクト; Microsoft Macro Assembler 8.0 (MASM) パッケージ (x86 用) Micro-Processor Services, Inc. Has converter tools and migration services to translate from MASM to C language. Now, MASM is only shipped with Visual Studio. VS 2003 shipped with MASM 7.0. VS 2005 shipped with MASM 8.0. VS 2008 shipped with MASM 9.0. I assume VS 2010 will ship.
|
History
The earliest versions of MASM date back to 1981. [2]
Up to 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 1992, added high-level programming support and a more C-like syntax. By the end of the year, version 6.1A updated the memory management to be compatible with code produced by Visual C++. In 1993 full support for 32-bit applications and the Pentium instruction set was added. The MASM binary at that time was shipped as a 'bi-modal' DOS-extended binary (using the Phar Lap TNT DOS extender).
Versions 6.12 to 6.14 were implemented as patches for version 6.11. These patches changed the type of the binary to native PE format; version 6.11 is the last version of MASM that will run under MS-DOS.
By the end of 1997 MASM fully supported Windows 95 and included some AMD-specific instructions.[4]
In 1999 Intel released macros for SIMD and MMX instructions, which were shortly after 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.[4] Support for 64-bit processors was not added until the release of Visual Studio 2005, with MASM given the version number 8.0.
MASM assembly language details
MASM has been the main vehicle for preserving the earlier Intel assembler notation and it can still be written as a fully specified language, a format that many disassemblers produce.
The OFFSET operator
If a data label is referenced in an expression, MASM will generally assume that the content of the memory reference is to be targeted. To access the address and not the content of a data label, MASM supplies addditional operators - OFFSET and SEG - to tell the assembler the different intention:
The OFFSET operator is not required to get the address of code labels; it is accepted, but ignored.
Square bracket operator []
The square bracket operator behaves differently depending on the context. For direct addressing, the square brackets are similar to the + operator. As a result, square brackets around a data label have no effect:
However, if the square brackets are used to enclose general purpose registers (GPR), the operator has a different meaning: now it is indicating that the register(s) enclosed is/are to be used as base or index register(s) for indirect memory addressing.
Type coercion with the PTR operator
MASM's built-in PTR operator may be used to a) set a type for an 'untyped' memory reference or b) override the type for a data label. The semantics are quite similar to C typecasts.
Argument type checking
From at least version 6.0, MASM has supported a high-level notation for creating procedures that perform argument size and count checking. It is part of a system using the PROC ENDP PROTO and INVOKE directives. The PROTO directive is used to define prototypes, PROC/ENDP pairs define so-called procedures. Both can then be called with the INVOKE directive, which includes argument size and argument count checking. Using those directives is optional.
Using an example prototype from the 32 bit Windows API function set,
The code to call this function using the INVOKE notation is as follows.
Which is translated exactly to,
The 64-bit version of MASM (ML64) did not as of 2011 support INVOKE.
Calling conventions
MASM supports a number of different calling conventions on both the 16 bit real mode DOS operating system, the 16 bit Windows versions and the later 32 bit versions. MASM supports the C, SYSCALL, STDCALL, BASIC, FORTRAN and PASCALcalling conventions.[5]
High-level control loops
MASM provides a notation to emulate a variety of high level control and loop structures.
It supports the .IF block structure,
It also supports the .WHILE loop structure,
And the .REPEAT loop structure.
The high level emulation also supports C runtime comparison operators that work according to the same rules as Intel mnemonic comparisons.[6]
The 64-bit version of Masm (ML64) does not support these features.
Preprocessor
MASM has a very powerful preprocessor that has considerably more functionality than C preprocessors. The MASM preprocessor is an integral part of the assembler and hence has access to the assembler's symbol table and expression evaluator. Seen from the outside, the preprocessor consists of
- assembly-time conditional directives IF, IFDEF, IFB, IFIDN, ...
- string manipulation and query directives CATSTR, SUBSTR, INSTR, ...
- assembly-time loop directives REPEAT, WHILE, FOR, FORC,...
- MACRO, EXITM and GOTO directives
- operators, i.e. OPATTR, that allows to detect a symbol's type at assembly-time.
Using the EXITM <return item> notation a macro can return a value or register in a way that can be used similar to a function call. A very simple example:
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, MASM is able to produce object modules in the Portable Executable[7][8] (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.
Some third-party tools that support MASM
IDEs
- RadASM[9]
- WinAsm Studio[10]
- EasyCode[11]
Debuggers
- OllyDbg[12]
Disassemblers
- IDAPro the Interactive Disassembler
Assemblers compatible with MASM
Some other assemblers can assemble most code written for MASM, with the exception of more complex macros.
- Pelle's Macro Assembler, a component of the Pelles C development environment.
- JWASM Macro Assembler, licenced under the Sybase Open Watcom EULA.
- Turbo Assembler (TASM) developed by Borland, later owned by Embarcadero, last updated in 2002 and supplied with Delphi and C++Builder for several years, later discontinued.
See also
- Assemblers
Footnotes
- ^MASM download page from Microsoft, non-commercial use only
- ^Watt, Peggy; Christine McGeever (January 7, 1985). 'Macintosh Vs. IBM PC At One Year'. InfoWorld7 (1): pp. 15–16. ISSN0199-6649. http://books.google.com/books?id=-i4EAAAAMBAJ&pg=PA16. The IBM PC Macro Assembler was released in December 1981.
- ^Marshall, Martin (April 29, 1991). 'Macro Assembler Update Adds High-Level Features'. InfoWorld13 (17): p. 21. ISSN0199-6649. http://books.google.com/books?id=y1AEAAAAMBAJ&pg=PT20.
- ^ abR. E. Harvey (2007). 'Assemblers'. Archived from the original on 16 February 2008. http://web.archive.org/web/20080216121237/http://ourworld.compuserve.com/homepages/r_harvey/doc_book.htm. Retrieved 4 February 2010.
- ^ ALANG.HLP standard installation Masm 6.11d
- ^http://www.intel.com/products/processor/manuals/
- ^http://download.microsoft.com/download/e/b/a/eba1050f-a31d-436b-9281-92cdfeae4b45/pecoff.doc
- ^http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx
- ^http://radasm.cherrytree.at/
- ^http://www.winasm.net/
- ^http://www.easycode.cat/English/index.htm
- ^http://www.ollydbg.de/
External links
|
SASM (SimpleASM) - simple Open Source crossplatform IDE for NASM, MASM, GAS, FASM assembly languages. SASM has syntax highlighting and debugger. The program works out of the box and is great for beginners to learn assembly language. SASM is translated into Russian, English, Turkish (thanks Ali Goren), Chinese (thanks Ahmed Zetao Yang), German (thanks Sebastian Fischer), Italian (thanks Carlo Dapor), Polish (thanks Krzysztof Rossa), Hebrew (thanks Elian Kamal), Spanish (thanks Mariano Cordoba). Licensed under the GNU GPL v3.0. Based on the Qt.
Download for Windows
Download for Linux
To load SASM for Linux choose your distribution in window 'Build Results' on the right.
Also you can build SASM from sources, placed in GitHub repository or download SASM in zip-archive for Windows.
If you are Mac user, this article about installing SASM on Mac may help you (thanks Brian R. Hall).
Contribute to SASM
WebMoney: Z282016332582 or R331674303467
About the program
In SASM you can easily develop and execute programs, written in NASM, MASM, GAS or FASM assembly languages. Enter code in form and simply run your program. In Windows SASM can execute programs in separate window. Enter your input data in 'Input' docking field. In 'Output' field you can see the result of the execution of the program. Wherein all messages and compilation errors will be shown in the form on the bottom. You can save source or already compiled (exe) code of your program to file and load your programs from file.
SASM supports working with many opened projects – new files are opened and created in new tabs. At the exit from SASM current set of opened files saved. At the next start you can restore previous session. In settings you can set font, color scheme and initial text. SASM is translated into Russian, English, Turkish (thanks Ali Goren), Chinese (thanks Ahmed Zetao Yang), German (thanks Sebastian Fischer), Italian (thanks Carlo Dapor), Polish (thanks Krzysztof Rossa), Hebrew (thanks Elian Kamal), Spanish (thanks Mariano Cordoba). All dialog windows in SASM is docking - you can choose one of many positions of them position. Also it is possible to reassign the hotkeys.
Standard 'Edit' menu extended with abilities to comment/uncomment piece of source code and to create/delete indent with 4 spaces (Tab/Shift+Tab).
In my program you can debug programs using the interface to the debugger gdb. You can watch values of variables and registers. Also you can set breakpoints and move through debugged program. In additional it is possible to perform any gdb command and see its result in the log on the bottom part of window.
SASM supports 4 working with assemblers - NASM, MASM, GAS and FASM in 2 modes - x64 and x86. You can choose mode in settings on 'Build' tab. Also there you can change assembler and linker options and choose programs for assembling and linking.
Troubleshooting
If you have something does not work (errors occur when compiling, debugging, etc.), please read the chapter 'Troubleshooting' in the help of the program (F1) or on the project Wiki on GitHub. Perhaps there you will find useful advice to solve your problems.
'io.inc' NASM macro library
SASM includes crossplatform input/output library 'io.inc' for NASM. It contains I/O macro and 2 additional macro: CMAIN - entry point and CEXTERN for invoking functions, located in C language libraries ('CEXTERN printf' for example).Macro name | Description |
PRINT_UDECsize, data PRINT_DEC size, data | Print number data in decimal representation. size – number, giving size of data in bytes - 1, 2, 4 or 8 (x64).data must be number or symbol constant, name of variable, register or address expression without size qualifier (byte[], etc.). PRINT_UDEC print number as unsigned, PRINT_DEC — as signed. |
PRINT_HEXsize, data | Similarly previous, but data is printed in hexadecimal representation. |
PRINT_CHARch | Print symbol ch. ch - number or symbol constant, name of variable, register or address expression without size qualifier (byte[], etc.). |
PRINT_STRINGdata | Print null-terminated text string. data - string constant, name of variable or address expression without size qualifier (byte[], etc.). |
NEWLINE | Print newline ('n'). |
GET_UDECsize, data GET_DECsize, data | Input number data in decimal representation from stdin. size – number, giving size of data in bytes - 1, 2, 4 or 8 (x64). data must be name of variable or register or address expression without size qualifier (byte[], etc.). GET_UDEC input number as unsigned, GET_DEC — as signed. It is not allowed to use esp register. |
GET_HEXsize, data | Similarly previous, but data is entered in hexadecimal representation with 0x prefix. |
GET_CHARdata | Similarly previous, but macro reads one symbol only. |
GET_STRINGdata, maxsz | Input string with length less than maxsz. Reading stop on EOF or newline and 'n' writes in buffer. In the end of string 0 character is added to the end. data - name of variable or address expression without size qualifier (byte[], etc.). maxsz - register or number constant. |
Implementation
Windows
As NASM assembler used nasm 2.11.02, as linker - gcc 4.6.2 from MinGW (gcc 4.8.1 from MinGW64 in x64 mode) or ld 2.22 from MinGW (ld 2.23.2 from MinGW64 in x64 mode).
SASM 3.0 and greater contains fasm 1.71.39 and gas 2.23.1 from MinGW (gas 2.23.2 from MinGW64).
Also SASM contains gdb debugger from MinGW and 'io.inc' macro library.
All assemblers (excluding MASM) are included in SASM and you can use they right away after their choice. MASM assembler can not be included in the assembly because of its license. To use it, you should install MASM on your computer from site https://www.masm32.com/ and specify path to MASM assembler (ml.exe, path usually 'C:/masm32/bin/ml.exe') and to MASM linker (link.exe, path usually 'C:/masm32/bin/link.exe') in according fields on 'Build' tab in settings.
On Windows SASM is ready for work immediately after installation.
Linux
For correct working on Linux must be installed next packages: nasm or gas (if you will use they, fasm already included in SASM), gcc, gdb (for debugging). MASM in Linux is not supported.
More information about SASM you can see on project Wiki on GitHub.
Changelog:
03.02.2020 - version 3.11.1 (zip, exe):
- Fix for uncomment keyboard shortcut.
31.01.2020 - version 3.11.0 (zip, exe):
- Bugs in interaction with GDB 8 fixed.
- Register parsing bug fixed.
- Crashing after clicking in memory window fixed (thanks Hofmer13).
- Debug hotkey miss bug fixed.
- Bug that prevented to open files without extension fixed.
- Saving file before building feature added.
- Search for selected text feature added.
- Italian translation fixed (thanks Mek101).
08.10.2018 - version 3.10.1 (zip, exe):
- Fix for lack of macro object in the linking options after 3.10.0 update.
01.10.2018 - version 3.10.0 (zip, exe):
- BSD OS support (thanks Martinfx).
- Fix for not working debugging on systems where gcc has default PIE option (thanks lberserq).
- Spanish language added (thanks Mariano Cordoba).
- Small settings usability fixes.
12.09.2017 - version 3.9.0 (zip, exe):
- More convinient memory expression watches have been added.
- Debugger crash bug has been fixed (thanks lberserq).
- Polish language translation has been added (thanks Krzysztof Rossa).
- Hebrew language translation has been added (thanks Elian Kamal).
19.02.2017 - version 3.8.0 (zip, exe):
- Registers parsing while debugging has been improved.
- Build in current directory option has been added.
- Italian language translation has been added.
30.10.2016 - version 3.7.0 (zip, exe):
- Chinese language has been added.
- German language has been added.
- Bug with single application crashes has been fixed.
- Bug with unprintable characters in program output has been fixed.
25.09.2016 - version 3.6.0:
- Turkish language has been added.
- Tab key action has been improved.
26.08.2016 - version 3.5.1:
- Drag & drop bug, debugging bug and some small bugs have been fixed.
19.03.2016 - version 3.5.0:
- GoLink linker support.
- Bug with wrong file names when saving and opening has been fixed.
11.02.2016 - version 3.4.0:
- Ability to change line number font color.
- Ability to switch off debug string insertion.
27.01.2016 - version 3.3.0:
- Single window mode.
- Drag & drop for file opening.
- Improved help: extended troubleshooting chapter and new building system settings chapter.
- A lot of bugs have been fixed including bug with non-native paths on Windows and bug with FPU registers showing.
14.06.2015 - version 3.2.0:
- Ability to build programs without running linker.
- New FASM 1.71.39.
- Fix of some debug problems.
27.05.2015 - version 3.1.4: fix of localized systems debug problem.
30.03.2015 - version 3.1.3: showing description of received signal has been added.
27.03.2015 - version 3.1.2: debugging files with include has been improved.
24.03.2015 - version 3.1.1: bugs with syntax higlighting have been fixed.
29.08.2014 - version 3.1.0: changes from pull requsts and issues from GitHub - movable tabs, warning message for wrong assembler or linker executable, improve indent operation, noexecstack option for binaries in Linux.
24.07.2014 - version 3.0.1: additional registers view in debugger has been added.
13.07.2014 - version 3.0:
- New assemblers have been added: now NASM, GAS, MASM, FASM are supported, including syntax highlighting, debugging, and x86/x64 modes. Added ability to choose your own assembler or linker filling path to them.
- Many improvements in debugging. Now it is possible to debug programs even without debugging information for GDB (for example, written in MASM). The ability to suspend the program has been added, as well as set a breakpoint during its execution.Added folder for include files.
- Fixed problem with text editor leads to a heavy load on the processor while opening big files. Fixed a bug with the disruption of the interface after opening the settings window. Fixed many minor bugs and errors.
23.04.2014 - version 2.3.1: bug with spaces in the path to temporary directory was fixed (now SASM works on Windows XP).
03.04.2014 - version 2.3:
- Abilities of mode selection (x64 or x86) and assembler and linker options change were added. Added tools for compilation and debugging 64-bit code.
- 64-bit instruction and registers and NASM macro assembler highlighting was implemented. 'io.inc' library adapted for using in 64-bit applications.
- Many bugs were fixed.
16.02.2014 - version 2.2:
Masm 8.0
- Significantly improvements of SASM interface and usability. Full color and syntax highlighting customization. All widgets become docking windows with many variants of them location. Register and memory widgets improved, ability of saving their state. Icons and toolbars added.
- Breakpoints improved. Macro debugging improved.
- Hotkeys improvements and ability of them rebinding.
13.11.2013 - version 2.1:
- Many bugs fixed, compatibility problems fixed - installation packages for a lot of Linux systems created, compatibility with Qt 4 added, making from sources improved.
- Many improvements added, functionality expanded. In debugger added: registers and memory watches, breakpoints, continue command; improved: performing gdb commands, current line highlighting, sequential output in debugging, 'io.inc' macro changed.
- Compilation in temporary folder. Mark of unsaved document. Sequential output in programs. Status of finishing of program. Time of execution of program. Font choosing.
- Help updated. New icon. Yet many minor improvements and features.
04.06.2013 - version 2.0: debugger has implemented, highlighting has been improved, many files support added, SASM (new name) has been rewrited on Qt and has become Open Source and crossplatform. Sources and new site is placed on GitHub.
21.04.2013 - version 1.0.4 - CEXTERN bug fixed.
18.03.2013 - version 1.0.3 - highlighting bug fixed, MASM bug fixed.
10.03.2013 - version 1.0.2 - bugs fixed, code autosaving added.
Assembler For Windows 10
07.03.2013 - first version of SASM - 1.0.0.
Wishes and reports send to e-mail: Dman1095@gmail.com or left on GitHub issues.
Microsoft Assembler X64
Copyright © 2013 Dmitriy Manushin