Struct sbrain::SBrainVM
[−]
[src]
pub struct SBrainVM { /* fields omitted */ }
A virtual machine modelling the SBrain Turing machine. This machine implements the specification relatively strictly, providing exactly 216 (65536) data and instruction cells. Thus, all pointers are 16 bits and all data is 32 bits. The main deviation from the minimum specification is the jump stack, which is indefinitely expandable.
Methods
impl SBrainVM
[src]
fn new(input_t: Option<Vec<MData>>) -> SBrainVM
Return a new SBrainVM, with no data in any tapes.
fn load_program(&mut self, program: &[u8]) -> Result<(), String>
Load a program tape: copy data from the given slice into the executable tape. On error, the Err(s) return will contain a message describing the error.
fn load_data(&mut self, data: &[MData]) -> Result<(), String>
Load a data tape: copy data from the given slice into the VM's data tape. On error, the Err(s) return will contain a message describing the error.
fn get_output(&self) -> Vec<MData>
Return a copy of the output data of the machine
fn run(&mut self, cycles: Option<u32>) -> (u32, bool)
Run the machine, until completion (cycles = None) or for n cycles (cycles = Some(n)). Return values are number of cycles run and why the machine stopped: false if due to a program halt (instr 31), false if due to running out of cycles.