|
1 | | -# Irridation: A Rust based Interpreter |
| 1 | +# Iridation: A VM and Assembler in Rust |
2 | 2 |
|
3 | | -[](https://github.com/FabioCanavarro/Irridation/actions/workflows/rust.yml) |
| 3 | +[](https://github.com/FabioCanavarro/Irridation/actions/workflows/rust.yml) |
4 | 4 |
|
5 | | -This is a passion project of mine trying to create a Programming language, I have almost finish the Assembly language. |
| 5 | +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. |
6 | 6 |
|
7 | | -## Future updates |
8 | | -- A language using the Assembly language i have made. |
9 | | -- Concurrency |
10 | | -- Http connections |
| 7 | +## Features |
11 | 8 |
|
| 9 | + - **Custom Assembly Language**: A simple instruction set designed for the Iridation VM. |
| 10 | + - **Two-Phase Assembler**: Processes labels and directives in the first pass and assembles bytecode in the second. |
| 11 | + - **Register-Based VM**: Executes bytecode with a set of 32 general-purpose registers. |
| 12 | + - **Interactive REPL**: An interactive shell for running assembly code line-by-line, with commands to inspect the VM state. |
| 13 | + - **Command Line Interface**: Run `.iasm` files directly from the command line, powered by `clap`. |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +```bash |
| 18 | +# Clone the repository |
| 19 | +git clone https://github.com/FabioCanavarro/Irridation |
| 20 | +cd Irridation |
| 21 | + |
| 22 | +# Build with Cargo |
| 23 | +cargo build --release |
| 24 | +``` |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +You can either execute an `.iasm` assembly file or launch the interactive REPL. |
| 29 | + |
| 30 | +### Running a File |
| 31 | + |
| 32 | +To assemble and run a program from a file: |
| 33 | + |
| 34 | +```bash |
| 35 | +# Run a .iasm file |
| 36 | +cargo run --release -- path/to/your/file.iasm |
| 37 | +``` |
| 38 | + |
| 39 | +### Interactive REPL |
| 40 | + |
| 41 | +Start the REPL by running the program without any arguments: |
| 42 | + |
| 43 | +```bash |
| 44 | +# Start the interactive REPL |
| 45 | +cargo run --release |
| 46 | +``` |
| 47 | + |
| 48 | +The REPL supports several commands for controlling the VM and inspecting its state: |
| 49 | + |
| 50 | + - **`.quit`**: Exits the REPL session. |
| 51 | + - **`.history`**: Displays all commands entered during the session. |
| 52 | + - **`.program`**: Shows the bytecode currently loaded in the VM. |
| 53 | + - **`.registers`**: Prints the current values of all 32 registers. |
| 54 | + - **`.clear`**: Clears the program from the VM's memory. |
| 55 | + - **`.load_file`**: Prompts for a file path to load an `.iasm` file into the VM. |
| 56 | + |
| 57 | +## Implementation Details |
| 58 | + |
| 59 | +### Assembler Architecture |
| 60 | + |
| 61 | +Iridation uses a two-phase assembler to handle code translation: |
| 62 | + |
| 63 | +1. **First Pass**: The assembler scans the source code to identify and record all labels and directives in a symbol table. |
| 64 | +2. **Second Pass**: It then converts the assembly instructions into their corresponding bytecode, using the symbol table to resolve label addresses. |
| 65 | +3. The final output is a bytecode executable with a custom 64-byte PIE (Program Information Executable) header. |
| 66 | + |
| 67 | +## Future Enhancements |
| 68 | + |
| 69 | + - A higher-level language that compiles down to Iridation assembly. |
| 70 | + - Concurrency support within the VM. |
| 71 | + - Networking capabilities for HTTP connections. |
0 commit comments