To learn assembly language and know how it works, first of all there is a need to set up the environment. Just like you need to have a device to do programming - a laptop, or any equivalent compatible device, and a Linux or Windows operating system, you will need an assembler software.
Set up Assembly Environment
We need a good assembler to write assembly code, convert it to machine language and track the run time of the code, etc. There are many good assembler programs, such as - NASM Assembler, Microsoft Assembler (MASM), Borland Turbo Assembler (TASM) ), GNU Assembler (GAS), EMU8086, etc.
We will be using NASM assembler to learn assembly language as you can download it for free from various web sources. Well documented and you'll find a lot of info on the net. It can be used on both Linux and Windows to write 16-bit, 32-bit and 64-bit programs.
Installing NASM
If you're a Linux user, NASM may come pre-installed on your operating system and you don't need to download and install it separately. To check if you already have NASM installed, follow these steps -
- Open a Linux terminal.
- Type whereis nasm and press ENTER.
If it's already installed, a line like nasm: /usr/bin/nasm appears. Otherwise you'll just see nasm: , then you'll need to install NASM.
How to Install NASM on Linux
To install NASM on Linux, follow these steps −
- See the Netwide Assembler (NASM) website for the latest version.
- Download the Linux source archive nasm-X.XX.ta.gz , where X.XX is the NASM version number in the archive.
- Unpack the archive into a directory which creates a subdirectory nasm-X. XX.
- cd to nasm-X.XX and type ./configure. This shell script will find the best C compiler to use and set up Makefiles accordingly.
- Type make to build the nasm and ndisasm binaries.
- Type make install to install nasm and ndisasm in /usr/local/bin and to install the man pages.
This should install NASM on your system. Alternatively, you can use an RPM distribution for the Fedora Linux. This version is simpler to install, just double-click the RPM file.
How to Install NASM on Windows.
If you want to edit and execute assembly language programs with nasm on Windows, you need to install NASM on Windows using DOSBox.
Follow these steps to install NASM on Windows
- download NASM and DOSBOX
- Install DOXSBOX
- Extract NASM in a Folder
- Run DoxBox
- Mount NASM folder to a Drive using “ mount [driveletter] [NASM Path]
For example we have extracted NASM on F:\Assebmly then here is command to mount it to X Drive
---> mount X f:\assembly Type x: x:\>