Assignment 2
Assignment 2
Submitted By:
Eman Iftikhar
Submitted To:
Sir Aoun
Department:
BS Computer Science (6th)
Subject:
Computer organization & Assembly language
Topic:
Place to stand with access to tools
Place to stand
NASM’s tools
Roll No:
01
- Installing NASM: Download and install NASM on your system. NASM is available
for various operating systems, including Windows, macOS, and Linux.
- Text Editor or IDE: Choose a text editor or Integrated Development Environment
(IDE) that supports assembly language syntax highlighting and possibly debugging.
Some popular choices include Visual Studio Code, Notepad++, and Emacs.
- Assembler and Debugger: NASM comes with its own assembler. You may also
need a debugger like GDB (GNU Debugger) to debug your assembly code.
Setting Up NASM
To start using NASM, you need to:
1. Download and install NASM: Get the latest version of NASM from the official
website or a trusted source.
2. Choose a text editor or IDE: Select a text editor or Integrated Development
Environment (IDE) that supports assembly language syntax highlighting and possibly
debugging.
3. Familiarize yourself with NASM syntax: Understand the syntax and directives
used by NASM for assembly language programming.
NASM's Development Environment
NASM provides a comprehensive development environment, including:
1. Assembler: The NASM assembler translates assembly code into machine code.
2. Preprocessor: The NASM preprocessor allows for macro expansion, conditional
assembly, and file inclusion.
3. Output formats: NASM supports various output formats, such as binary, ELF, COFF,
and Mach-O.
1. Flexibility: NASM supports a wide range of output formats and can be used on
various operating systems.
2. Powerful preprocessor: NASM's preprocessor allows for complex macro expansion
and conditional assembly.
3. Large community: NASM has a large and active community, providing resources,
documentation, and support.
NASM’s Tools
NASM (Netwide Assembler) provides several tools and utilities to facilitate assembly
language programming. Here are some of the key tools:
1. NASM Assembler
The NASM assembler is the core tool for translating assembly code into machine code.
It supports a wide range of output formats, including:
- Binary: Outputs a flat binary file containing the assembled machine code.
- ELF: Outputs an ELF (Executable and Linkable Format) file, commonly used on
Linux and other Unix-like systems.
- COFF: Outputs a COFF (Common Object File Format) file, used on some Windows
and Unix systems.
- Mach-O: Outputs a Mach-O file, used on macOS.
2. NASM Preprocessor
The NASM preprocessor provides features like:
- Macro expansion: Allows defining and expanding macros in assembly code.
- Conditional assembly: Enables conditional inclusion of code based on defined
symbols or expressions.
- File inclusion: Allows including other files into the assembly source code.
## 3. Other Utilities
NASM may include or be accompanied by other utilities, such as:
- Other tools: Depending on the NASM distribution, other tools might be included for
tasks like debugging or code optimization.
1. Write assembly code: Create assembly language source files using a text editor or
IDE.
2. Assemble the code: Use the NASM assembler to translate the assembly code into
machine code.
3. Link the object files: If necessary, link the object files together to create an
executable file.
4. Debug the code: Use a debugger like GDB to step through the code, inspect
registers, and memory.
By mastering NASM's tools, you can efficiently develop and debug assembly
language programs.