Skip to content

PavleProd/Sistemski-Softver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

System Programming Project / Projekat iz Sistemskog Softvera

This repository implements a comprehensive toolchain for an abstract computer system, developed to provide a foundational understanding of how compilers and emulators work. The project includes three primary components: an assembler, a linker, and an emulator, each with clearly defined functionalities.

It is a project on the course System Programming ("Sistemski Softver") on University of Belgrade, Faculty of Electrical Engineering, Module for Computer Engineering and Informatics

Key Features and Functionalities

1. Assembler

The assembler is a single-pass tool that translates imaginary assembly language code into machine-readable code. Here are some of the main assembly directives and symbols:

  • Symbol Handling:
    • .global directive exports symbols for use in other modules.
    • .extern directive imports symbols from other modules.
  • Memory Organization:
    • .section directive defines new code or data sections.
    • .word directive allocates memory and initializes it with provided values.
    • .skip directive reserves uninitialized memory of a specified size.
  • Code Translation:
    • Converts assembly instructions into binary format.
    • Supports instructions like halt, int, call, jmp, and arithmetic operations such as add, sub, mul, and div.
  • Output Generation:
    • Produces a relocatable object file in a custom ELF-inspired format.

2. Linker

The linker combines object files generated by the assembler into a complete executable program or relocatable output. Key functionalities include:

  • Section Aggregation: Merges sections with the same name from multiple input files without overlaps.
  • Memory Mapping:
    • Uses -place=<section>@<address> to assign explicit addresses to sections.
  • Output Formats:
    • Generates hexadecimal files (-hex option) for memory initialization.
    • Reports errors if symbols are undefined or sections overlap.

3. Emulator

The emulator executes programs generated by the linker and simulates the behavior of the abstract computer system. Key features include:

  • Processor Emulation:
    • Simulates a 32-bit processor with general-purpose registers, a program counter (pc), and a stack pointer (sp).
    • Executes machine instructions atomically.
  • Interrupt Handling:
    • Manages hardware interrupts (e.g., timer and terminal) and software interrupts (int).
  • Program Execution:
    • Reads input files in hexadecimal format, executes instructions, and halts upon encountering the halt instruction.

Workflow

  1. Assembly: Use the assembler to convert assembly code into an object file.
  2. Linking: Combine multiple object files using the linker to create a final executable.
  3. Execution: Run the executable on the emulator and monitor the system's behavior.

Testing

You can test the source code provided in test folder by starting start.sh in terminal

About

Compiler and Emulator for Imaginary Computer System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published