Skip to content

itaybroder/Assembler-in-C

Repository files navigation

Assembler Project

This is the readme file for the "Assembler" project developed for the university. The project is implemented in the C programming language and aims to provide an assembler for a specific architecture.

Introduction

The Assembler project is designed to convert assembly language programs into machine code for a specific architecture. It takes assembly code as input and generates the corresponding machine code that can be executed on the target architecture.

The project is implemented in C programming language and follows a modular approach for easy understanding and extensibility. It aims to provide a flexible and efficient solution for assembling assembly language programs.

Features

The Assembler project offers the following features:

  1. Parsing: The assembler parses assembly code to identify instructions, labels, and operands.
  2. Symbol Table: It maintains a symbol table to keep track of labels and their corresponding addresses.
  3. Code Generation: The assembler generates machine code by translating assembly instructions and resolving addresses.
  4. Error Handling: It provides comprehensive error handling and reporting for syntax errors, undefined labels, and other issues.
  5. Modularity: The codebase is designed with modularity in mind, allowing easy extensibility and future improvements.

Installation

To install and set up the Assembler project, follow these steps:

  1. Clone the repository: git clone <https://github.com/itaybroder/Assembler-in-C>
  2. Navigate to the project directory: cd Assembler-in-C
  3. Compile the source code: gcc -o assembler main.c assembler.c
  4. The assembler executable will be generated.

Usage

To use the Assembler project, follow these steps:

  1. Prepare your assembly code in a text file, e.g., input.asm.
  2. Run the assembler executable: ./assembler input.asm
  3. The assembler will process the input file and generate the corresponding machine code.
  4. If there are any errors or warnings, they will be displayed on the console.
  5. The generated machine code can be found in the output file, which will have the same name as the input file but with a different extension, e.g., input.obj.

Examples

Here are a few examples to demonstrate the usage of the Assembler project:

; Example 1: Hello World
section .data
    message db "Hello, World!",0

section .text
    global _start

_start:
    ; write the message to stdout
    mov eax, 4
    mov ebx, 1
    mov ecx, message
    mov edx, 13
    int 0x80

    ; exit the program
    mov eax, 1
    xor ebx, ebx
    int 0x80

Save the above code in a file named hello.asm and assemble it using the Assembler project:

./assembler hello.asm

The generated machine code will be stored in the hello.obj file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published