CpuState

Struct CpuState 

Source
pub struct CpuState {
Show 22 fields pub a: u8, pub x: u8, pub y: u8, pub s: u8, pub pc: u16, pub p: u8, pub mpr: [u8; 8], pub high_speed: bool, pub mpr_latch: u8, pub irq1: bool, pub irq2: bool, pub tiq: bool, pub irq_disable: u8, pub halted: bool, pub reset_pending: bool, pub maskable_interrupt_pending: bool, pub non_maskable_interrupt_pending: bool, pub polled_i: Option<bool>, pub polled_maskable_interrupt: Option<bool>, pub polled_non_maskable_interrupt: Option<bool>, pub skipped_poll: bool, pub polled_irq_lines: Option<u8>,
}
Expand description

Complete CPU-owned state at an instruction boundary.

Registers, the mapping registers, the clock switch, the three maskable interrupt inputs and their disable gate, and the frame’s poll state (the requests the host has made and the core has not yet taken, and what decides the next step()). Host memory, devices, scheduling and cycle counters are excluded: restoring this value restores the processor, not a machine. The fields from halted to skipped_poll are 6502-rust’s frame’s, as in its CpuState; polled_irq_lines is this core’s.

Fields§

§a: u8§x: u8§y: u8§s: u8§pc: u16

Logical, 16 bits.

§p: u8

P as the core keeps it: T is bit 5, B (bit 4) is never stored (U4, U5).

§mpr: [u8; 8]

MPR0-MPR7.

§high_speed: bool§mpr_latch: u8

The last value TAM or TMA moved (what TMA #$00 returns; U11).

§irq1: bool

The IRQ1, IRQ2 and TIQ input levels and the disable register (IRQ2, IRQ1, TIQ; 1 = masked).

§irq2: bool§tiq: bool§irq_disable: u8§halted: bool

Always false: the HuC6280 has no JAM, WAI or STP.

§reset_pending: bool§maskable_interrupt_pending: bool

An enabled maskable source is asserted.

§non_maskable_interrupt_pending: bool

An NMI edge latched and not yet taken.

§polled_i: Option<bool>

The I flag the last instruction’s poll saw, when that differs in timing from P (CLI, SEI, PLP); None otherwise.

§polled_maskable_interrupt: Option<bool>

The IRQ line and the NMI latch as the last poll saw them, when that is not what the requests above say; None when the poll agrees with them.

§polled_non_maskable_interrupt: Option<bool>§skipped_poll: bool

The last step was BRK, an interrupt entry or reset, which do not poll: the next boundary runs an instruction.

§polled_irq_lines: Option<u8>

The maskable lines the last instruction’s poll saw (IRQ2, IRQ1, TIQ in bits 0-2, the $1403 layout), when a line changed after the poll, in the instruction’s last cycle; None when the poll saw irq1, irq2 and tiq as they stand. It picks the vector and decides a vanished interrupt (C18). Added in issue 0005; None, the default, is how a state from before it loads.

Implementations§

Source§

impl CpuState

Source

pub fn poll_fields(&self) -> PollFields

The frame’s fields of this state.

Source

pub fn validate(&self) -> Result<(), String>

Check what the reference’s constructor enforces beyond the field widths: irq_disable in 0..=7, polled_irq_lines None or in 0..=7, and B (bit 4 of P) clear.

Trait Implementations§

Source§

impl Clone for CpuState

Source§

fn clone(&self) -> CpuState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CpuState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CpuState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for CpuState

Source§

fn eq(&self, other: &CpuState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for CpuState

Source§

impl Eq for CpuState

Source§

impl StructuralPartialEq for CpuState

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.