Crates.io | ram-machine |
lib.rs | ram-machine |
version | 2.0.1 |
source | src |
created_at | 2024-02-03 20:35:50.227867 |
updated_at | 2024-03-02 13:10:58.65627 |
description | RAM machine code interpreter |
homepage | |
repository | https://github.com/kamack38/ram-machine |
max_upload_size | |
id | 1125630 |
size | 96,150 |
This repo contains a code for a RAM Machine code parser and interpreter as defined by Łukasz Szkup in his Master Thesis
From crates.io
cargo install ram-machine
From GitHub
cargo install --git https://github.com/kamack38/ram-machine
RAM machine code interpreter
Usage: ram [OPTIONS] <COMMAND>
Commands:
run Run ram machine code from file
check Validates ram code syntax of a given file
init Generate a shell completion file
debug Run ram machine code and see the tape, input, output for each instruction
help Print this message or the help of the given subcommand(s)
Options:
-q, --quiet Don't pass code output to STDOUT
-h, --help Print help
-V, --version Print version
To generate TAB completion file for a given shell run
ram init <shell>
ram run file.ram 1 2 3 4
ram debug examples/three_sum.ram 1 2 3
Here's the debug output:
╭───╮
│ 0 │
├───┤
│ ? │
╰───╯
Input: 1 2 3
Output:
Next instruction: READ 1
╭───┬───╮
│ 0 │ 1 │
├───┼───┤
│ ? │ 1 │
╰───┴───╯
Input: 1 2 3
Output:
Next instruction: READ 0
╭───┬───╮
│ 0 │ 1 │
├───┼───┤
│ 2 │ 1 │
╰───┴───╯
Input: 1 2 3
Output:
Next instruction: READ 2
╭───┬───┬───╮
│ 0 │ 1 │ 2 │
├───┼───┼───┤
│ 2 │ 1 │ 3 │
╰───┴───┴───╯
Input: 1 2 3
Output:
Next instruction: ADD 1
╭───┬───┬───╮
│ 0 │ 1 │ 2 │
├───┼───┼───┤
│ 3 │ 1 │ 3 │
╰───┴───┴───╯
Input: 1 2 3
Output:
Next instruction: ADD 2
╭───┬───┬───╮
│ 0 │ 1 │ 2 │
├───┼───┼───┤
│ 6 │ 1 │ 3 │
╰───┴───┴───╯
Input: 1 2 3
Output:
Next instruction: WRITE 0
╭───┬───┬───╮
│ 0 │ 1 │ 2 │
├───┼───┼───┤
│ 6 │ 1 │ 3 │
╰───┴───┴───╯
Input: 1 2 3
Output: 6
Next instruction: HALT