MASM, TASM, FASM, NASM for Windows and Linux
Part I
Part II
Part III
In this article I want to consider questions that may arise in a person who has started to study assembler related to installing various translators and translating programs for Windows and Linux, as well as provide links to resources and books devoted to studying this Topics.
Used to create drivers for Windows.
On the link go to the website and download the package (masm32v11r.zip). After installing the program, a folder with our package C: \ masm32 is created on the disk. Create a program prog11.asm that does nothing.
We assemble (translate) the prog11.asm file using the assembler from the masm32 website .

The / coff switch is used here to broadcast 32-bit programs.
Linking is done with the link / subsystem: windows prog11.obj command ( link / subsystem: console prog11.obj )
As stated on Wikipedia
Also, assembler version 6. can be taken on the website of Kip Irwin kipirvine.com/asm , the author of the book "Assembly Language for Intel Processors".
By the way, here is a link to the personal site of Vladislav Pirogov, author of the book “Assembler for Windows”.
MASM from the Microsoft website
Next, download MASM (version 8.0) from the Microsoft website using the link . The downloaded file is called "MASMsetup.exe". When you run this file, we get the message - "Microsoft Visual C ++ Express Edition 2005 required."
We open this file with an archiver (for example 7zip). Inside we see the setup.exe file, extract it, open the archiver. Inside we see two files vc_masm.msi, vc_masm1.cab. We extract the file vc_masm1.cab, open the archiver. Inside we see the file FL_ml_exe _____ X86.3643236F_FC70_11D3_A536_0090278A1BB8. Rename it to the fl_ml.exe file, then, assemble the prog11.asm file using the fl_ml.exe assembler.

MASM in Visual Studio
MASM can also be found in the folder with Visual Studio (I have VS 10) here: C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin \ ml.exe.

In order to run on a 32-bit or 64-bit system and create programs that work under both 32-bit and 64-bit Windows, MASM32 (ml.exe, fl_ml.exe) is suitable. In order to work on 32-bit and 64-bit systems and create programs running on 64-bit Windows, but not working on 32-bit, you need the ml64.exe assembler. Lies in the folder C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin \ amd64 and here it is C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin \ x86_amd64.
Borland software package for developing assembly language programs for x86 architecture. Borland has now stopped distributing its assembler.
You can download, for example, here . There is no installer, just extract the program. Here is the source code from Peter Abel’s book (Figure 3.2), Assembler Language for IBM PC and Programming.
Assemble (translate) the abel32.asm file.

The correctness of the program can be checked by linking (tlink.exe) the object file and running the resulting file in the debugger.
As mentioned above, MASM can be used to work with 16-bit programs. Perform assemble (broadcast) abel32.asm program using MASM assembler:

Key / coff is not used here.
Linking is done by link16.exe
In an article by Chris Kaspersky “Comparison of assembler translators” it is written that “FASM is an extraordinary and very original, but alas, toy assembler. Suitable for small tasks such as "hello, world", viruses, demos and other works of hacker creativity. "
Download FASM from the official site . There is no installer, just extract the program. Open fasm editor - C: \ fasm \ fasmw.exe. In the folder C: \ fasm \ EXAMPLES \ HELLO there is a file HELLO.asm.
Open the HELLO.asm file from fasmw.exe. Change the line include 'win32ax.inc' to the line include 'c: \ fasm \ INCLUDE \ WIN32AX.INC'. Run from the menu Run → Run.

Here are links to FASM resources:
→ FASM on Cyberforum
→ FASM on asmworld .com programs under Dos
→ Series of articles “Assembler for Windows for Dummies”
→ Website on the FASM narod
on Linux
In order to use FASM on Linux (I have Ubuntu), download the appropriate distribution kit (fasm-1.71.60.tgz), unpack it, we will have the binary file fasm in the folder, copy this file to / usr / local / bin in order to so that you can run it from the console, like any other command. Assemble the hello.asm program from the fasm / examples / elfexe / hello.asm folder.

The correctness of the program can be checked in the debugger.
Nasm successfully competes with the standard on Linux and many other UNIX systems assembler Gas.
Nasm on Linux can be installed using the package manager or from the command line: in the Debian distribution (Ubuntu) with the apt-get install nasm command , in Fedora , CentOS , RedHat distributions with the yum install nasm command .
Create a program that displays the “Hello” message 5 times. An example is taken from the book by Andrei Viktorovich Stolyarov “Programming in Assembly Language NASM for OS UNIX”. The textbook, as well as the library “stud_io.inc” is on the author’s personal website .
Assemble and link and run the hello.asm file.
For 64bit, you must use the command nasm -f elf64 hello.asm
NASM for Windows
NASM for Windows can be installed by downloading the appropriate distribution package from the corresponding site .
Assembling:
Links to Nasm resources:
→ A.V. Website Stolyarova
→ The site on which the electronic textbook is located (in the archive)
→ The same
Standard assembler in almost all varieties of UNIX, including Linux and BSD. The free version of this assembler is called GAS (GNU assembler). Allows you to broadcast programs using the GCC compiler.
From textbooks, only a book in English “Programming from the ground up” was found. In Russian, only one chapter was found from the book by S. Zubkov “Assembler for DOS, Windows and UNIX”.
Take an example of a program that does nothing from the site . Let's create the gas.s program
Perform assembly (translation), linking and launching the program:
If in this program you change _start to main, then you can perform assembly (translation) and linking by the gcc compiler.
Perform assembly (translation), linking and launching the program:
Conclusions : if you study programming under Windows, then you can opt for Masm; Tasm is no longer supported, but is suitable for learning from old classical textbooks.
For Linux, Gas is suitable for those who use GCC, and for those who do not like the Gas syntax, Nasm is suitable.
PS The following two parts are generally devoted to processing a string in a loop.
PPS Little Man Computer - A training computer model with a limited set of assembler instructions is discussed in this article .
Part II
Part III
In this article I want to consider questions that may arise in a person who has started to study assembler related to installing various translators and translating programs for Windows and Linux, as well as provide links to resources and books devoted to studying this Topics.
MASM
Used to create drivers for Windows.
On the link go to the website and download the package (masm32v11r.zip). After installing the program, a folder with our package C: \ masm32 is created on the disk. Create a program prog11.asm that does nothing.
.586P
.model flat, stdcall
_data segment
_data ends
_text segment
start:
ret
_text ends
end start
We assemble (translate) the prog11.asm file using the assembler from the masm32 website .

The / coff switch is used here to broadcast 32-bit programs.
Linking is done with the link / subsystem: windows prog11.obj command ( link / subsystem: console prog11.obj )
As stated on Wikipedia
MASM is one of the few Microsoft development tools for which there were no separate 16- and 32-bit versions.
Also, assembler version 6. can be taken on the website of Kip Irwin kipirvine.com/asm , the author of the book "Assembly Language for Intel Processors".
By the way, here is a link to the personal site of Vladislav Pirogov, author of the book “Assembler for Windows”.
MASM from the Microsoft website
Next, download MASM (version 8.0) from the Microsoft website using the link . The downloaded file is called "MASMsetup.exe". When you run this file, we get the message - "Microsoft Visual C ++ Express Edition 2005 required."
We open this file with an archiver (for example 7zip). Inside we see the setup.exe file, extract it, open the archiver. Inside we see two files vc_masm.msi, vc_masm1.cab. We extract the file vc_masm1.cab, open the archiver. Inside we see the file FL_ml_exe _____ X86.3643236F_FC70_11D3_A536_0090278A1BB8. Rename it to the fl_ml.exe file, then, assemble the prog11.asm file using the fl_ml.exe assembler.

MASM in Visual Studio
MASM can also be found in the folder with Visual Studio (I have VS 10) here: C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin \ ml.exe.

In order to run on a 32-bit or 64-bit system and create programs that work under both 32-bit and 64-bit Windows, MASM32 (ml.exe, fl_ml.exe) is suitable. In order to work on 32-bit and 64-bit systems and create programs running on 64-bit Windows, but not working on 32-bit, you need the ml64.exe assembler. Lies in the folder C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin \ amd64 and here it is C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin \ x86_amd64.
Tasm
Borland software package for developing assembly language programs for x86 architecture. Borland has now stopped distributing its assembler.
You can download, for example, here . There is no installer, just extract the program. Here is the source code from Peter Abel’s book (Figure 3.2), Assembler Language for IBM PC and Programming.
stacksg segment para stack 'stack'
db 12 dup ('stackseg')
stacksg ends
codesg segment para 'code'
begin proc far
assume ss:stacksg,cs:codesg,ds:nothing
push ds
sub ax,ax
push ax
mov ax, 0123h
add ax, 0025h
mov bx,ax
add bx,ax
mov cx,bx
sub cx,ax
sub ax,ax
nop
ret
begin endp
codesg ends
end begin
Assemble (translate) the abel32.asm file.

The correctness of the program can be checked by linking (tlink.exe) the object file and running the resulting file in the debugger.
As mentioned above, MASM can be used to work with 16-bit programs. Perform assemble (broadcast) abel32.asm program using MASM assembler:

Key / coff is not used here.
Linking is done by link16.exe
Fasm
In an article by Chris Kaspersky “Comparison of assembler translators” it is written that “FASM is an extraordinary and very original, but alas, toy assembler. Suitable for small tasks such as "hello, world", viruses, demos and other works of hacker creativity. "
Download FASM from the official site . There is no installer, just extract the program. Open fasm editor - C: \ fasm \ fasmw.exe. In the folder C: \ fasm \ EXAMPLES \ HELLO there is a file HELLO.asm.
include 'win32ax.inc'
.code
start:
invoke MessageBox,HWND_DESKTOP,"Hi! I'm the example program!",invoke GetCommandLine,MB_OK
invoke ExitProcess,0
.end start
Open the HELLO.asm file from fasmw.exe. Change the line include 'win32ax.inc' to the line include 'c: \ fasm \ INCLUDE \ WIN32AX.INC'. Run from the menu Run → Run.

Here are links to FASM resources:
→ FASM on Cyberforum
→ FASM on asmworld .com programs under Dos
→ Series of articles “Assembler for Windows for Dummies”
→ Website on the FASM narod
on Linux
In order to use FASM on Linux (I have Ubuntu), download the appropriate distribution kit (fasm-1.71.60.tgz), unpack it, we will have the binary file fasm in the folder, copy this file to / usr / local / bin in order to so that you can run it from the console, like any other command. Assemble the hello.asm program from the fasm / examples / elfexe / hello.asm folder.

The correctness of the program can be checked in the debugger.
Nasm
Nasm successfully competes with the standard on Linux and many other UNIX systems assembler Gas.
Nasm on Linux can be installed using the package manager or from the command line: in the Debian distribution (Ubuntu) with the apt-get install nasm command , in Fedora , CentOS , RedHat distributions with the yum install nasm command .
Create a program that displays the “Hello” message 5 times. An example is taken from the book by Andrei Viktorovich Stolyarov “Programming in Assembly Language NASM for OS UNIX”. The textbook, as well as the library “stud_io.inc” is on the author’s personal website .
%include "stud_io.inc"
global _start
section .text
_start: mov eax, 0
again: PRINT "Hello"
PUTCHAR 10
inc eax
cmp eax, 5
jl again
FINISH
Assemble and link and run the hello.asm file.
$ nasm -f elf hello.asm
$ ld hello.o -o hello
$ ./hello
For 64bit, you must use the command nasm -f elf64 hello.asm
NASM for Windows
NASM for Windows can be installed by downloading the appropriate distribution package from the corresponding site .
Assembling:
nasm -f bin имя_файла.asm -o имя_файла.com
Links to Nasm resources:
→ A.V. Website Stolyarova
→ The site on which the electronic textbook is located (in the archive)
→ The same
As
Standard assembler in almost all varieties of UNIX, including Linux and BSD. The free version of this assembler is called GAS (GNU assembler). Allows you to broadcast programs using the GCC compiler.
From textbooks, only a book in English “Programming from the ground up” was found. In Russian, only one chapter was found from the book by S. Zubkov “Assembler for DOS, Windows and UNIX”.
Take an example of a program that does nothing from the site . Let's create the gas.s program
.section .text
.globl _start
_start:
movl $1, %eax
movl $2, %ebx
int $0x80
Perform assembly (translation), linking and launching the program:
$ as -o gas.o gas.s
$ ld -o gas gas.o
$ ./gas
If in this program you change _start to main, then you can perform assembly (translation) and linking by the gcc compiler.
.section .text
.globl main
main:
movl $1, %eax
movl $2, %ebx
int $0x80
Perform assembly (translation), linking and launching the program:
$ gcc gas.s -o gas
$ ./gas
Conclusions : if you study programming under Windows, then you can opt for Masm; Tasm is no longer supported, but is suitable for learning from old classical textbooks.
For Linux, Gas is suitable for those who use GCC, and for those who do not like the Gas syntax, Nasm is suitable.
PS The following two parts are generally devoted to processing a string in a loop.
PPS Little Man Computer - A training computer model with a limited set of assembler instructions is discussed in this article .