[][src]Struct emulator::cpu::Cpu

pub struct Cpu { /* fields omitted */ }

Cpu of the 2i.

Represents the 8 bit cpu of the 2i with 8 registers that are 8 bit wide and the three status registers (carry, negative, zero).

Examples:

use emulator::{Cpu, Instruction, Ram};

let mut cpu = Cpu::new();
let mut ram = Ram::new();

// R0 = 6
let inst = Instruction::new(0b00_00000_00_000_0110_01_01_1100_0).unwrap();

let _ = cpu.execute_instruction(inst, &mut ram);
assert_eq!(6, cpu.inspect_registers()[0]);

Methods

impl Cpu[src]

pub fn new() -> Cpu[src]

Create a new cpu with all registers and flags set to zero.

pub fn execute_instruction<B: Bus>(
    &mut self,
    inst: Instruction,
    bus: &mut B
) -> Result<(usize, Flags)>
[src]

Execute the given instruction on the cpu using the given, bus, input and output. Returns the address of the next instruction and the alu flags.

pub fn trigger_volatile_interrupt(&mut self)[src]

Enable the volatile interrupt (MAC 010) for the next instruction executed

pub fn trigger_stored_interrupt(&mut self)[src]

Enable the stored interrupt (MAC 111) until used by any instruction

pub fn inspect_registers(&mut self) -> &mut [u8; 8][src]

Direct access to the registers.

pub fn inspect_flags(&mut self) -> &mut Flags[src]

Direct access to the flag register.

pub fn check_volatile_interrupt(&self) -> bool[src]

Check if the volatile interrupt is active for the next instruction

pub fn check_stored_interrupt(&self) -> bool[src]

Check if the stored interrupt is active

Trait Implementations

impl Default for Cpu[src]

Auto Trait Implementations

impl Send for Cpu

impl Sync for Cpu

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.