[−][src]Struct emulator::cpu::Cpu
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]
&mut self,
inst: Instruction,
bus: &mut B
) -> Result<(usize, Flags)>
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
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,