Struct Cpu

Source
pub struct Cpu {
    pub memory: MemoryBus,
    pub registers: Registers,
    pub flags: StatusFlags,
    pub stack: Stack,
}
Expand description

A representation of a 6502 microprocessor

Fields§

§memory: MemoryBus§registers: Registers§flags: StatusFlags§stack: Stack

Implementations§

Source§

impl Cpu

Source

pub fn new() -> Cpu

Returns a default instance of a Cpu

Source

pub fn load<T>(&mut self, code: &[u8], addr: T) -> Result<(), CpuError>
where T: Into<Option<u16>>,

Loads code into the Cpu main memory at an optional offset. If no offset is provided, the Cpu will, by default, load the code into main memory at 0xC000

Source

pub fn step_n(&mut self, n: u32) -> Result<u64, CpuError>

Runs N instructions of code through the Cpu

Source

pub fn reset(&mut self)

Source

pub fn step(&mut self) -> CpuStepResult

Runs a single instruction of code through the Cpu

Source

pub fn nmi(&mut self)

Execute the Non-Maskable Interrupt handler. This ignores the interrupt flag and forces execution to the NMI

Source

pub fn irq(&mut self)

Execute the Interrupt ReQuest handler if we currently are accepting maskable interrupts. Ignore it otherwise.

Auto Trait Implementations§

§

impl Freeze for Cpu

§

impl RefUnwindSafe for Cpu

§

impl Send for Cpu

§

impl Sync for Cpu

§

impl Unpin for Cpu

§

impl UnwindSafe for Cpu

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.