nasm-system-calls-examples

Nasm x86 Assembly System Calls and Interacting with OS

This repository contains exercises and examples focused on system calls and interacting with the operating system using assembly language. These examples are built using NASM assembler on a Windows x64 environment, and they illustrate how to interact with OS services at a low level.

Table of Contents

Introduction

This repository explores advanced concepts in assembly language, focusing on making system calls and interacting with the OS directly. It includes practical examples that demonstrate how to:

Prerequisites

Before running the examples in this repository, ensure you have the following tools installed:

Setup

  1. Clone the repository:
    git clone https://github.com/kavicastelo/assembly_system_calls_and_interacting_with_os.git
    ccd assembly_system_calls_and_interacting_with_os
    
  2. Install NASM and MinGW-w64: Follow the instructions from their official websites:
  3. Set up environment variables: Make sure NASM and MinGW-w64 are accessible from the command line by adding their installation paths to your system’s PATH environment variable.

Exercises

Exercise 1: Simple System Call

This exercise demonstrates how to make a basic system call to print a message to the console.

Exercise 2: File Reading System Call

This exercise shows how to read a file using system calls and print its contents.

Exercise 3: Process Management

This exercise explores process management, including creating and managing processes via system calls.

Running the Examples

To assemble and link the examples, follow these steps:

  1. Assemble the code:
    nasm -f win64 <filename>.asm -o <filename>.o
    
  2. Link the code:
    gcc -m64 -o <filename> <filename>.o -lkernel32 -lmsvcrt
    
  3. Execute the code:
    .\<filename>.exe
    

Replace <filename> with the specific example you are running.

References

Contributing

Contributions are welcome! If you have any suggestions, bug fixes, or improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.