5 个版本
使用旧的 Rust 2015
0.2.1 | 2020年12月28日 |
---|---|
0.2.0 | 2020年12月28日 |
0.1.2 | 2016年7月8日 |
0.1.1 | 2016年6月22日 |
0.1.0 | 2016年6月22日 |
在 机器学习 中排名 370
89KB
1.5K SLoC
Reustmann - 冯·诺依曼架构
Reustmann 是 Rust 中的冯·诺依曼架构。我受到了 Dave Miller 的 Iota 机器 的启发。
我只是将它重新创建在 Rust 中。
如何使用
在 hello_world.rm
程序中,确保您没有添加一个最后的换行符
Gp..OOOOOOOOOOOOHTFello World!
首先创建一个程序,例如一个文件
extern crate reustmann;
use std::fs::File;
use reustmann::Program;
let program = Program::from_file("./hello_world.rm").unwrap();
然后使用此程序填充解释器内存
use reustmann::Interpreter;
let arch_length = 50; // memory length
let arch_width = 8; // word size
let mut interpreter = Interpreter::new(arch_length, arch_width).unwrap();
interpreter.copy_program(&program).unwrap();
然后您可以使用解释器运行它
use reustmann::Statement;
use reustmann::instruction::op_codes;
use std::io::{empty, stdout};
// use std::io::sink; // for no output
let mut input = empty(); // no input data needed
let mut output = stdout(); // output on the standard output
loop {
// each interpreter step return a statement
// while no `HALT` statement is found, we continue
match interpreter.step(&mut input, &mut output) {
Statement(op_codes::HALT, _) => break,
_ => ()
}
}
您可以在任何时候获取调试信息
// put this in the previous match, in the right position!
println!("{:?}", interpreter.debug_infos());
依赖项
~3.5MB
~65K SLoC