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.
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.
The Assembler project offers the following features:
- Parsing: The assembler parses assembly code to identify instructions, labels, and operands.
- Symbol Table: It maintains a symbol table to keep track of labels and their corresponding addresses.
- Code Generation: The assembler generates machine code by translating assembly instructions and resolving addresses.
- Error Handling: It provides comprehensive error handling and reporting for syntax errors, undefined labels, and other issues.
- Modularity: The codebase is designed with modularity in mind, allowing easy extensibility and future improvements.
To install and set up the Assembler project, follow these steps:
- Clone the repository:
git clone <https://github.com/itaybroder/Assembler-in-C>
- Navigate to the project directory:
cd Assembler-in-C
- Compile the source code:
gcc -o assembler main.c assembler.c
- The assembler executable will be generated.
To use the Assembler project, follow these steps:
- Prepare your assembly code in a text file, e.g.,
input.asm
. - Run the assembler executable:
./assembler input.asm
- The assembler will process the input file and generate the corresponding machine code.
- If there are any errors or warnings, they will be displayed on the console.
- 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
.
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.