[−][src]Struct ttk91::emulator::Emulator
The emulator contains all neccessary context for executing a TTK91 program and interfaces for doing IO.
Fields
memory: Mem
The memory of the emulated machine. Contains all the instructions and data required by the program. Implements Memory.
context: Context
The execution context, which includes the registers and flags of the CPU.
io: IO
Interface for doing IO operations and supervisor calls.
halted: bool
True if the execution has been halted.
Implementations
impl<Mem, IO> Emulator<Mem, IO> where
Mem: Memory,
IO: InputOutput,
[src]
Mem: Memory,
IO: InputOutput,
pub fn new(memory: Mem, io: IO) -> Result<Emulator<Mem, IO>, Mem::Error>
[src]
Create a new emulator.
Parameters
memory
: A Memory object which has the program.io
: An IO handler.
Returns
A new Emulator instance.
pub fn with_logger<L>(
memory: Mem,
io: IO,
logger: L
) -> Result<Emulator<Mem, IO>, Mem::Error> where
L: Into<Option<Logger>>,
[src]
memory: Mem,
io: IO,
logger: L
) -> Result<Emulator<Mem, IO>, Mem::Error> where
L: Into<Option<Logger>>,
Create a new emulator.
Parameters
memory
: A Memory object which has the program.io
: An IO handler.logger
: A logger for debug information.
Returns
A new Emulator instance.
pub fn set_logger(&mut self, logger: Logger)
[src]
pub fn add_listener<L>(&mut self, listener: L) where
L: EventListener + 'static,
[src]
L: EventListener + 'static,
Start sending events to the specified listener.
pub fn get_current_instruction(&mut self) -> Result<Instruction, Mem::Error>
[src]
Fetches the instruction from the address pointed by the Program Counter register.
pub fn emulate_instruction(
&mut self,
ins: &Instruction
) -> Result<(), Mem::Error>
[src]
&mut self,
ins: &Instruction
) -> Result<(), Mem::Error>
Executes a single instruction.
Does not increment the PC
register or do anything else related to the instruction
fetching.
Errors
Returns a memory error if the instruction tries to execute an illegal memory operation.
pub fn step(&mut self) -> Result<(), Mem::Error>
[src]
Fetches the next instruction, increments the program counter and executes the instruction.
Errors
Returns a memory error if the instruction tries to execute an illegal memory operation.
pub fn run(&mut self) -> Result<(), Mem::Error>
[src]
Executes the program until it halts the execution or .
Errors
Returns a memory error if the instruction tries to execute an illegal memory operation.
Auto Trait Implementations
impl<Mem, IO> !RefUnwindSafe for Emulator<Mem, IO>
impl<Mem, IO> !Send for Emulator<Mem, IO>
impl<Mem, IO> !Sync for Emulator<Mem, IO>
impl<Mem, IO> Unpin for Emulator<Mem, IO> where
IO: Unpin,
Mem: Unpin,
IO: Unpin,
Mem: Unpin,
impl<Mem, IO> !UnwindSafe for Emulator<Mem, IO>
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> 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>,