The NASM Handbook: Everything You Need to Know to Get Started
Assembly programming is often seen as a niche but essential skill for understanding how software interacts directly with hardware. In this…
The NASM Handbook: Everything You Need to Know to Get Started
Assembly programming is often seen as a niche but essential skill for understanding how software interacts directly with hardware. In this blog, we’ll explore NASM — the Netwide Assembler — and guide you through its basics, practical uses, and even walk you through writing your first program. Whether you’re a hobbyist or a seasoned developer looking to optimize your code, this post will help you grasp NASM in a clear, step-by-step manner.
What is NASM?
NASM, or the Netwide Assembler, is an open-source assembler for the x86 architecture. Known for its clarity and modular design, NASM translates human-readable assembly code into machine code. Its straightforward syntax and extensive documentation make it a popular choice for those learning low-level programming and for professionals developing performance-critical software.
Why We Use NASM?
NASM offers several compelling advantages:
Efficiency and Performance: By providing direct control over hardware resources, NASM allows you to write highly optimized code.
Educational Value: Working with NASM deepens your understanding of computer architecture and how high-level languages eventually execute on a processor.
Portability: NASM supports multiple operating systems, making it an adaptable tool for various development environments.
Vibrant Community: With a wealth of tutorials, forums, and documentation available, you’re never far from support when tackling assembly language challenges.
How can we use NASM?
NASM (Netwide Assembler) is a popular choice for writing assembly code on the x86 architecture. However, modern operating systems sometimes make it challenging to run legacy software or 16-bit assembly programs directly. This is where DOSBox comes in — a DOS emulator that provides a controlled environment for running older applications. In this guide, we’ll walk you through setting up DOSBox, installing NASM for DOS, and creating a simple assembly program.
Why Use DOSBox?
DOSBox emulates a DOS environment on modern systems, allowing you to run legacy applications and tools that were originally designed for DOS. For NASM enthusiasts and learners, DOSBox provides:
An Isolated Environment: Experiment with assembly programming without risking your main operating system.
Compatibility: Run 16-bit assembly programs and older versions of NASM that may not work natively on contemporary operating systems.
Ease of Setup: DOSBox is relatively straightforward to install and configure, making it an ideal choice for beginners.
Step 1: Installing DOSBox
For Windows:
-
Visit the DOSBox website and download the latest installer.
-
Run the installer and follow the on-screen instructions to complete the installation.
For Linux/macOS:
Linux: Open your terminal and run:
sudo apt-get install dosbox
Step 2: Installing NASM for DOS
-
Go to the official NASM website and download the NASM executable suitable for DOS (typically named NASM.EXE).
-
Create a folder on your system to store NASM (for example, C:\NASM on Windows).
-
Copy the NASM.EXE file into this folder.
Step 3: Configuring DOSBox
After installing DOSBox and NASM, you need to set up DOSBox to recognize the folder where NASM is located.
-
Launch DOSBox.
-
Mount the NASM Directory: In the DOSBox command prompt, type:
mount C C:\NASM
(Replace C:\NASM with the path to your NASM folder if it’s different.)
- Switch to the Mounted Drive:
C:
- Verify Installation: Run the following command:
nasm -v
If installed correctly, NASM will display its version information.
Step 4: Writing a Simple Assembly Program
Let’s create a simple program that adds two numbers. You can use the built-in DOS text editor for this purpose.
- Open the Editor: Write this simple code in it.
[org 0x0100]
mov ax, 10
mov bx, 150
add ax, bx
mov bx, 200
add ax, bx
mov ax, 0x4c00
int 0x21a
-
Save this file Save this file where you install the NASM. Extension of this file is .asm .
-
Launch DOSBox.
-
Mount the NASM Directory: In the DOSBox command prompt, type:
mount C C:\NASM
(Replace C:\NASM with the path to your NASM folder if it’s different.)
- Switch to the Mounted Drive:
C:
- Write this command nasm first.asm -o f1.com then afd f1.com (Replace first.asm with your file name.)
Explanation of afd screen
When you run the last cmd then you found this window that is given below

Fig 1: afd Screen
This screen is known as afd screen. For easy understanding of this screen we can divide it into 7parts. That are given below
- Registers and Flags Section(Top)
- cmd Section(Left)
- Binary And Assembly Code Section(Left Middle)
- M1 Section(Right Middle)
- M2 Section(Right Bottom)
- ASCII Interpretation (Bottom-Right)
- Status Bar (Bottom Line)
1. Registers and Flags Section
The iAPX88 architecture consists of 14 registers. In assembly language we play with them. All these registers are given below

Fig 2: Registers
When we run any line of code the values of these registers, stacks and flags will be change. We can see the change with respect to each line of code by window that is on the top of afd screen. Figure given below

Fig 3: Registers and Flags Section
2. cmd Section
If we want to write any cmd like quit, L1 first.asm or anyone else in it window then we use this cmd section.

Fig 4: cmd Section
3. Binary And Assembly Code Section
In this section we can see different kind of things. i. memory address of line of code(offset). ii. Binary translation of our assembly code line. known as off code. iii. Our code line. iv. Which instruction is being execute.

FIg 5: Binary And Assembly Code Section
4. M1 Section
i. M1 is the first memory location or register that the program is working with. ii. It shows the current value of a number that is being used in an operation. iii. If you move a number into a register (like AX), that register is shown as M1.

Fig 6: M1 Section
5. M2 Section
i. M2 is the second memory location or register involved in an operation. ii. It shows the value of another number that is interacting with M1. iii. If you are adding two numbers, the second number will be in M2.

Fig 7: M2 Section
6. ASCII Interpretation (Bottom-Right)
Interprets memory as ASCII characters. Some values may appear as readable characters, while others show dots (.) for non-printable bytes.

Fig 8: ASCII Interpretation
7. Status Bar (Bottom Line)
Displays debugging options: Step → Step through instructions. ProcStep → Step through procedures. Retrieve → Retrieve previous commands. Help, BRK Menu, up/down → Debugger controls. Conclusion

Fig 9: Status Bar
Conclusion
NASM remains a powerful tool for anyone interested in the intricacies of low-level programming. It offers a direct window into how computers operate, providing the control necessary for optimizing performance and understanding system internals. Whether you’re starting with your first “Adding two numbers” program or delving into more complex projects, NASM opens the door to mastering the art of assembly language.
메타데이터
- post_id
- b06616683fc7
- slug
- the-nasm-handbook-everything-you-need-to-know-to-get-started-b06616683fc7
- url
- https://medium.com/@usmanshakeel/the-nasm-handbook-everything-you-need-to-know-to-get-started-b06616683fc7
- canonical_url
- https://medium.com/@usmanshakeel/the-nasm-handbook-everything-you-need-to-know-to-get-started-b06616683fc7
- author_url
- https://medium.com/@usmanshakeel
- status
- ok
- fetched_at
- 2026-07-20 15:47:05