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.
- 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 byclap
.
# Clone the repository
git clone https://github.com/FabioCanavarro/Irridation
cd Irridation
# Build with Cargo
cargo build --release
You can either execute an .iasm
assembly file or launch the interactive REPL.
To assemble and run a program from a file:
# Run a .iasm file
cargo run --release -- path/to/your/file.iasm
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.
Iridation uses a two-phase assembler to handle code translation:
- First Pass: The assembler scans the source code to identify and record all labels and directives in a symbol table.
- Second Pass: It then converts the assembly instructions into their corresponding bytecode, using the symbol table to resolve label addresses.
- The final output is a bytecode executable with a custom 64-byte PIE (Program Information Executable) header.
- A higher-level language that compiles down to Iridation assembly.
- Concurrency support within the VM.
- Networking capabilities for HTTP connections.