[−][src]Struct pir_8_emu::binutils::pir_8_emu::Vm
Container for all data needed and/or useful for running a pir-8-emu
virtual machine
Examples
let mut vm = Vm::new("FSXYABCD").unwrap(); vm.reset("FSXYABCD", &[ Instruction::Halt.into(), Instruction::LoadImmediateWide { rr: InstructionLoadImmediateWideRegisterPair::Adr }.into(), 0x04, 0x20, Instruction::LoadImmediateByte { rrr: 0b000 }.into(), 0x69, Instruction::Save { rrr: 0b000 }.into(), Instruction::Halt.into(), ]); vm.jump_to_addr(0x0001).unwrap(); while !vm.execution_finished { vm.ins.reset_rw(); vm.perform_next_op().unwrap(); } assert_eq!(vm.memory[0x0420], 0x69);
Fields
memory: Memory
ports: Ports
registers: GeneralPurposeRegisterBank
pc: SpecialPurposeRegister<u16>
sp: SpecialPurposeRegister<u16>
adr: SpecialPurposeRegister<u16>
ins: SpecialPurposeRegister<u8>
ops: (MicroOpBlock, usize)
curr_op: usize
instruction: Instruction
instruction_valid: bool
If this is set, instruction
contains the current instruction and
ops
contains the μOps corresponding thereto
execution_finished: bool
stack: Vec<u8>
instruction_history: ArrayDeque<[(u16, Instruction, u16); 10], ArrayDequeBehaviourWrapping>
Any instruction successfully loaded will be added to the front of this queue
breakpoints: BTreeSet<u16>
Pause execution when PC is contained herein until the flag is cleared
active_breakpoint: Option<u16>
Methods
impl Vm
[src]
pub fn new(gp_reg_ltrs: &str) -> Result<Vm, i8>
[src]
Create a new, zero-initialised VM with the specified general-purpose register letters
pub fn reset(&mut self, gp_reg_ltrs: &str, memory: &[u8]) -> Result<(), i8>
[src]
Reset this VM to a default state but with the specified memory buffer
pub fn jump_to_addr(&mut self, to_addr: u16) -> Result<(), MicroOpPerformError>
[src]
Safely jump to the specified address
The current μOp set will be executed, then PC
updated to the specified address, and μOps set to
NEXT_INSTRUCTION
pub fn perform_next_op(&mut self) -> Result<bool, MicroOpPerformError>
[src]
Perform next μOp
If execution has finished, do nothing
Otherwise, perform the current μOp and bump the μOp counter
If the last μOp of the set has been performed:
- if
INS
was written to, load the instruction therein - otherwise, load
NEXT_INSTRUCTION
The returned value represents whether new μOps are present
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Vm
impl !Send for Vm
impl !Sync for Vm
impl Unpin for Vm
impl !UnwindSafe for Vm
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,