This is the Final project (mmn 14) in Laboratory C 20465- 2023B course at the Open University. This project was developed as part of the "20465 - Systems Programming Laboratory" 2023B course at the Open University. It's a comprehensive assembler program for a specific assembly language, written in C. The purpose is to simulate the operation of common system programs, and thus experience writing a large-scale software project.
βοΈ - βοΈ For private lessons and project assistance, please contact me at: a.shtaigmann@gmail.com βοΈ
Love this project? Has it helped you throughout the course? Please consider support. I put a lot of effort into making this project readable and easy to use!β€οΈ
Buy Me A Coffee is a simple way to support creators by buying them a virtual coffee. It's a platform where you can make small, one-time donations to show your appreciation.
The project consists of multiple C and header files, each serving a specific purpose in the program. It adheres to principles of clarity, readability, structured writing, and data abstraction.
The assembler works in three main stages:
- Pre-Processing
- First Pass
- Second Pass
These stages form the core algorithm of the assembler.
The pre-assembler reads the source file line by line and identifies macro definitions. If a macro is identified, the lines of the macro are added to a macro table and replaced in the source file.
The first pass identifies symbols (labels) and assigns them numerical values representing their corresponding memory addresses.
In the second pass, the assembler generates the final machine code, replacing operation names with their binary equivalents and symbol names with their assigned memory locations.
Details about the algorithms for these stages can be found in the documentation.
π Project Structure
repo
βββ Errors.c
βββ Errors.h
βββ Input_and_output_ex
βΒ Β βββ Invalid_input_1.am
βΒ Β βββ Invalid_input_1.as
βΒ Β βββ Invalid_input_2.am
βΒ Β βββ Invalid_input_2.as
βΒ Β βββ Invalid_input_3.as
βΒ Β βββ Invalid_input_4.as
βΒ Β βββ c_master.am
βΒ Β βββ c_master.as
βΒ Β βββ c_master.ent
βΒ Β βββ c_master.ext
βΒ Β βββ c_master.ob
βΒ Β βββ valid_input_1.am
βΒ Β βββ valid_input_1.as
βΒ Β βββ valid_input_1.ent
βΒ Β βββ valid_input_1.ext
βΒ Β βββ valid_input_1.ob
βΒ Β βββ valid_input_2.am
βΒ Β βββ valid_input_2.as
βΒ Β βββ valid_input_2.ent
βΒ Β βββ valid_input_2.ext
βΒ Β βββ valid_input_2.ob
βΒ Β βββ valid_input_3.as
βΒ Β βββ valid_input_4.as
βββ LICENSE
βββ README.md
βββ Readme_imgs
βΒ Β βββ Invalid1.png
βΒ Β βββ c_master_as.png
βΒ Β βββ valid_output1.png
βββ Tests
βΒ Β βββ AsemblerFiles-Test
βΒ Β βΒ Β βββ CourseExamle.am
βΒ Β βΒ Β βββ CourseExamle.ob
βΒ Β βββ TestC.c
βΒ Β βββ To-Test
βΒ Β βΒ Β βββ Almog
βΒ Β βΒ Β βΒ Β βββ AllOpcodeNames.txt
βΒ Β βΒ Β βΒ Β βββ Test4_01.am
βΒ Β βΒ Β βΒ Β βββ Test4_01.as
βΒ Β βΒ Β βΒ Β βββ Test4_01.ob
βΒ Β βΒ Β βΒ Β βββ longline.am
βΒ Β βΒ Β βΒ Β βββ longline.as
βΒ Β βΒ Β βΒ Β βββ test1.am
βΒ Β βΒ Β βΒ Β βββ test1.as
βΒ Β βΒ Β βΒ Β βββ test1.ent
βΒ Β βΒ Β βΒ Β βββ test1.ext
βΒ Β βΒ Β βΒ Β βββ test1.ob
βΒ Β βΒ Β βΒ Β βββ test1_02.am
βΒ Β βΒ Β βΒ Β βββ test1_02.as
βΒ Β βΒ Β βΒ Β βββ test1_02.ob
βΒ Β βΒ Β βΒ Β βββ test3_01.am
βΒ Β βΒ Β βΒ Β βββ test3_01.as
βΒ Β βΒ Β βΒ Β βββ test3_01.ob
βΒ Β βΒ Β βΒ Β βββ test_macro_01.am
βΒ Β βΒ Β βΒ Β βββ test_macro_01.as
βΒ Β βΒ Β βΒ Β βββ test_macro_01.ent
βΒ Β βΒ Β βΒ Β βββ test_macro_01.ext
βΒ Β βΒ Β βΒ Β βββ test_macro_01.ob
βΒ Β βΒ Β βββ Course_master
βΒ Β βΒ Β βΒ Β βββ c_master.am
βΒ Β βΒ Β βΒ Β βββ c_master.ent
βΒ Β βΒ Β βΒ Β βββ c_master.ext
βΒ Β βΒ Β βΒ Β βββ c_master.ob
βΒ Β βΒ Β βΒ Β βββ master.ob
βΒ Β βΒ Β βββ IdeasToTest.md
βΒ Β βΒ Β βββ Master.am
βΒ Β βΒ Β βββ Master.as
βΒ Β βΒ Β βββ Master.ob
βΒ Β βββ fist_pass_test.c
βΒ Β βββ test_preproc.c
βββ assembler
βββ assembler.c
βββ code_conversion.c
βββ code_conversion.h
βββ data_strct.c
βββ data_strct.h
βββ first_pass.c
βββ first_pass.h
βββ globals.h
βββ handle_text.c
βββ handle_text.h
βββ lexer.c
βββ lexer.h
βββ makefile
βββ preproc.c
βββ preproc.h
βββ second_pass.c
βββ second_pass.h
βββ t_linuix_1.am
βββ t_linuix_1.as
βββ t_linuix_1.ent
βββ t_linuix_1.ext
βββ t_linuix_1.ob
βββ t_linuix_2.as
βββ table.c
βββ table.h
βββ util.c
βββ util.h
8 directories, 94 files
Please switch to the linux
branch to run the project. Use the following instructions:
Before you begin, ensure that you have the following prerequisites installed:
βΉοΈ GCC compiler
βΉοΈ Ubuntu system (but others will also work)
- Clone the Labratory-C-Final-Project repository:
git clone https://github.com/AlmogShKt/Labratory-C-Final-Project.git
- Change to the project directory:
cd Labratory-C-Final-Project
- Checkout the Linux branch:!
git checkout linux
- Run Makefile to compile the program:
`make`
Run the compiled program using the following command: ./assembler file_name_1 ... file_name_N
This will output machine code generated from the provided assembly file.
This is valid input and output files:
And for Invalid output:
Several assembly language input files are provided to demonstrate the use of various operations and data types, as well as the assembler's handling of errors.
Each function in the source code is accompanied by concise, clear documentation in the form of header comments, explaining its purpose and usage. Important variables are also explained. Detailed comments are present throughout the code for better understanding.
This project does not accept contributions as of now.