Skip to content

This is the Final project (mmn 14, Project Grade - πŸ’―) in Laboratory C 20465- 2023B course at the Open University

License

Notifications You must be signed in to change notification settings

AlmogShKt/Labratory-C-Final-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Labratory-C-Final-Project πŸš€

Project Grade - πŸ’―

C-Final-Project

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"

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.


πŸ“– Table of Contents


🧩 Project Structure

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:

  1. Pre-Processing
  2. First Pass
  3. Second Pass

These stages form the core algorithm of the assembler.

Pre-Processing

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.

First Pass

The first pass identifies symbols (labels) and assigns them numerical values representing their corresponding memory addresses.

Second Pass

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
___

βš™οΈ Getting Started

βœ”οΈ Prerequisites

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)

πŸ“¦ Installation

  1. Clone the Labratory-C-Final-Project repository:
git clone https://github.com/AlmogShKt/Labratory-C-Final-Project.git
  1. Change to the project directory:
cd Labratory-C-Final-Project
  1. Checkout the Linux branch:!
git checkout linux
  1. Run Makefile to compile the program:
`make`

πŸ”§ Usage

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:



πŸ§ͺ Testing

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.


πŸ“š Documentation

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.


🀝 Contribution

This project does not accept contributions as of now.


πŸ‘πŸ» Almog Shtaimgann and Tamir Shemsh Β©

About

This is the Final project (mmn 14, Project Grade - πŸ’―) in Laboratory C 20465- 2023B course at the Open University

Resources

License

Stars

Watchers

Forks