[−][src]Struct lc3::vm::VM
A single LC-3 virtual machine. Each machines processes instructions in memory, handling appropriate I/O requests in device registers.
Note: memory-mapped I/O registers are not implemented as separated fields. The VM will treat device registers as normal words in the mem.
Note: Currently interrupts are not implemented.
Fields
register: [i16; 8]
General purpose registers(R0~R7)
pc: u16
Program Counter
ir: u16
Instruction Register
supervisor: bool
Supervisor mode
priority: u8
Priority Level(PL0~PL7)
condition: Condition
Condition codes
mem: [u16; 65536]
Computer memory
Methods
impl VM
[src]
pub fn new() -> VM
[src]
Returns a new, initialized LC-3 machine, with default operating system loaded.
pub fn load_u8(&mut self, program: &[u8])
[src]
Loads a program from raw u8 slice(generally, file contents).
Panics
This function panics if program
slice's length is not even or less than two(invalid header).
pub fn load_file(&mut self, path: &Path) -> Result<()>
[src]
Loads a program from given path of file.
Panics
This function panics if file contents' length is not even or less than two(invalid header).
pub fn load_u16(&mut self, entry: usize, program: &[u16])
[src]
Loads a program from u16 slice from entry point given, and set pc to it. All other load_* wrappers should convert given input program into u16 slice, and pass it to this method at the last.
Panics
This function panics if program size exceeds machine memory range.
(entry + program.len() >= 65536
)
pub fn psr(&self) -> u16
[src]
Calculates, and returns processor state register(PSR) value.
pub fn step<'a, R: Read, W: Write>(
&mut self,
input: &'a mut R,
output: &'a mut W
)
[src]
&mut self,
input: &'a mut R,
output: &'a mut W
)
Executes next single instruction. This function does not care about the clock enable bit.
pub fn step_n<'a, R: Read, W: Write>(
&mut self,
input: &'a mut R,
output: &'a mut W,
n: usize
)
[src]
&mut self,
input: &'a mut R,
output: &'a mut W,
n: usize
)
Executes next n instructions. This function does not care about the clock enable bit.
pub fn run<'a, R: Read, W: Write>(
&mut self,
input: &'a mut R,
output: &'a mut W
) -> usize
[src]
&mut self,
input: &'a mut R,
output: &'a mut W
) -> usize
Executes as much as instructions, while the clock enable bit is set to 1.
Returns number of instructions executed.
pub fn run_n<'a, R: Read, W: Write>(
&mut self,
input: &'a mut R,
output: &'a mut W,
n: usize
) -> usize
[src]
&mut self,
input: &'a mut R,
output: &'a mut W,
n: usize
) -> usize
Executes next n instructions at maximum, while the clock enable bit is set to 1.
Returns the number of instructions executed.
Trait Implementations
impl Clone for VM
[src]
fn clone(&self) -> VM
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for VM
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,