Skip to content

FabioCanavarro/Irridation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iridation: A VM and Assembler in Rust

Rust

A custom virtual machine (VM) and assembler for a simple, custom assembly language, built from the ground up in Rust. It features a CLI to run assembly files and an interactive REPL for live coding.

Features

  • Custom Assembly Language: A simple instruction set designed for the Iridation VM.
  • Two-Phase Assembler: Processes labels and directives in the first pass and assembles bytecode in the second.
  • Register-Based VM: Executes bytecode with a set of 32 general-purpose registers.
  • Interactive REPL: An interactive shell for running assembly code line-by-line, with commands to inspect the VM state.
  • Command Line Interface: Run .iasm files directly from the command line, powered by clap.

Installation

# Clone the repository
git clone https://github.com/FabioCanavarro/Irridation
cd Irridation

# Build with Cargo
cargo build --release

Usage

You can either execute an .iasm assembly file or launch the interactive REPL.

Running a File

To assemble and run a program from a file:

# Run a .iasm file
cargo run --release -- path/to/your/file.iasm

Interactive REPL

Start the REPL by running the program without any arguments:

# Start the interactive REPL
cargo run --release

The REPL supports several commands for controlling the VM and inspecting its state:

  • .quit: Exits the REPL session.
  • .history: Displays all commands entered during the session.
  • .program: Shows the bytecode currently loaded in the VM.
  • .registers: Prints the current values of all 32 registers.
  • .clear: Clears the program from the VM's memory.
  • .load_file: Prompts for a file path to load an .iasm file into the VM.

Implementation Details

Assembler Architecture

Iridation uses a two-phase assembler to handle code translation:

  1. First Pass: The assembler scans the source code to identify and record all labels and directives in a symbol table.
  2. Second Pass: It then converts the assembly instructions into their corresponding bytecode, using the symbol table to resolve label addresses.
  3. The final output is a bytecode executable with a custom 64-byte PIE (Program Information Executable) header.

Future Enhancements

  • A higher-level language that compiles down to Iridation assembly.
  • Concurrency support within the VM.
  • Networking capabilities for HTTP connections.

About

A custom assembly language of mine, that may be the foundation of my programming language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages