[][src]Struct ttk91::emulator::Emulator

pub struct Emulator<Mem, IO> {
    pub memory: Mem,
    pub context: Context,
    pub io: IO,
    pub halted: bool,
    // some fields omitted
}

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]

pub fn new(memory: Mem, io: IO) -> Result<Emulator<Mem, IO>, Mem::Error>[src]

Create a new emulator.

Parameters

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]

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]

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]

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

impl<Mem, IO> !UnwindSafe for Emulator<Mem, IO>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.