Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Labratory ©️

Course Language Grade

This is a 12-bit assembler for the System Programming Laboratory course (20465) at the Open University of Israel.
It is written in ANSI C (C89), follows a modular layout, and transforms .as sources into preprocessed .am files and Base64-encoded object output.


📖 Table of Contents


💡 A Glance

Topic Description
Project Type 12-bit assembler with deferred symbol resolution
Academic Context System Programming Laboratory (Open University)
Language ANSI C (C89)
Input / Output .as files -> .am, .ob (Base64), .ent, .ext

🧩 Project Structure

Project Map

Directory Responsibility
Assembler/ Orchestrates compilation, symbol handling, and backpatching.
Lexical_analysis/ Parses lines and classifies commands, directives, and operands.
preprocessor/ Handles macro expansion and writes the .am stage.
Output_files/ Generates .ob, .ent, and .ext files.
Data_structures/ Infrastructure for fast Trie lookups and dynamic Vector storage.

Flow Overview

The assembler operates in a modular pipeline: source files are expanded via the preprocessor, analyzed for lexical patterns, and then processed by the core logic to resolve labels and generate encoded machine words.

flowchart LR
	A[.as source] --> B[preprocessor]
	B --> C[.am file]
	C --> D[Lexical_analysis]
	D --> E[Assembler core]
	E --> F[Output_files]
	G[Trie + Vector] -. support .-> B
	G -. support .-> D
	G -. support .-> E
Loading

⚙️ Getting Started

1. Clone the Project

git clone https://github.com/guyGojanski/C_Assembler.git

2. Change to the project directory

cd C_Assembler

3. Environment Setup

Intall WSL from PowerShell as Administrator:

wsl --install

Complete the Ubuntu setup by creating a username and password.

4. Prerequisites

Inside your WSL terminal, install the required tools:

sudo apt update && sudo apt install build-essential

🏛️ Core Architecture

Pass Model: Single-Pass with Deferred Resolution

Unlike traditional two-pass designs, this assembler completes translation in one main scan of the .am file.

  • Scan stage: the assembler scans each line. Known symbols are emitted immediately. If an undefined label is encountered, a placeholder word is inserted.
  • Deferred fixups: a direct pointer to the placeholder's memory location is stored. Once the scan ends, the assembler backpatches these addresses directly in memory.
  • Relocation: data symbols are relocated once the final code size is known.

Strategic Data Structures

  • Trie: character-driven lookup providing $O(L)$ efficiency for reserved keywords and labels.
  • Vector: dynamic containers that avoid fixed-size limits and provide direct pointers for efficient backpatching.

🛠️ Build & Environment

Build Command

make

The project uses strict compiler flags:

  • -Wall
  • -ansi
  • -pedantic

Run Command

./assembler_program test/ok/ok1

🧪 Testing

Test Layout

test/
├── error/      # Intentional syntax and logic errors.
├── ok/         # Valid assembly cases for Base64 verification.
└── warning/    # Diagnostic warnings for non-critical issues.

Example Runs

./assembler_program test/ok/ok1 test/ok/ok2 test/ok/ok3
./assembler_program test/error/error
./assembler_program test/warning/warning1 test/warning/warning2

📝 Documentation

This README summarizes the project workflow, structure, build steps, and testing layout. The code is intentionally modular so each stage can be understood and maintained independently.

Developed by guy gojanski

About

Labratory-C-Final-Project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages