Skip to main content

Cpu8080State

Struct Cpu8080State 

Source
pub struct Cpu8080State {
Show 16 fields pub registers: Registers, pub pc: u16, pub sp: u16, pub flags: Flags, pub memory: Memory64K, pub interrupt_request_pending: bool, pub interrupt_enable: bool, pub interrupt_enable_pending: bool, pub halted: bool, pub cycle_count: u64, pub interrupt_vector_byte: Option<u8>, pub tact_phase: Option<u8>, pub last_completed_tact_phase: Option<u8>, pub last_fetched_opcode: u8, pub last_data_bus_byte: u8, pub last_address_bus: u16, /* private fields */
}

Fields§

§registers: Registers§pc: u16§sp: u16§flags: Flags§memory: Memory64K§interrupt_request_pending: bool§interrupt_enable: bool§interrupt_enable_pending: bool§halted: bool§cycle_count: u64§interrupt_vector_byte: Option<u8>§tact_phase: Option<u8>§last_completed_tact_phase: Option<u8>

Last executed T-phase of the current/just-finished instruction. tact_phase resets to None at boundaries; this field holds total - 1 at completion so the UI freezes on the final T. None only on cold start / Reset.

§last_fetched_opcode: u8

Mirror of the chip’s IR: holds the last opcode fetched on M1 until the next M1. After HLT a memory.read(pc) look-ahead would show NOP from blank RAM; the IR still reads 0x76.

§last_data_bus_byte: u8

Mirror of the chip’s data bus latch (D7-D0). After HLT it must show 0x76, not the byte at the new PC.

§last_address_bus: u16

Mirror of the chip’s address bus latch (A0-A15). PC, HL, SP, and 16-bit immediates take turns on it. After HLT PC=halt+1 but the latch still shows the HLT address.

Implementations§

Source§

impl Cpu8080State

Source

pub const RESET_SP: u16 = 0xFFFF

8080 leaves SP indeterminate on reset; the reference uses 0xFFFF so a stray PUSH lands in the high stack region.

Source

pub fn reset_cpu(&mut self)

Source

pub fn reset_ram(&mut self)

Source

pub fn request_interrupt(&mut self, vector_byte: u8)

Source

pub fn set_register(&mut self, register: RegisterName, value: u8)

Source

pub fn get_register(&self, register: RegisterName) -> u8

Source

pub fn set_memory(&mut self, address: u16, value: u8)

Source

pub fn set_memory_block( &mut self, start: u16, values: &[u8], ) -> Result<(), ValidationError>

Source

pub fn peek(&self, address: u16) -> u8

Side-effect-free read for UI/disassembler; executors go through bus_read* / bus_write* / fetch_opcode.

Source

pub fn step_instruction<B: PortBus>( &mut self, bus: &mut B, ) -> Result<InstructionOutcome, CoreError>

Source

pub fn timing_opcode(&self) -> u8

Source

pub fn timing_branch_taken(&self, layout: MachineCycleLayout, phase: u8) -> bool

Source

pub fn tact_walk_active(&self) -> bool

Source

pub fn run_for_t_states<B: PortBus>( &mut self, bus: &mut B, t_states: u64, ) -> Result<(), CoreError>

Source

pub fn run_until_halt<B: PortBus>( &mut self, bus: &mut B, max_instructions: u64, ) -> Result<u64, CoreError>

Source§

impl Cpu8080State

Source

pub fn step_tact<B: PortBus>( &mut self, bus: &mut B, ) -> Result<TactOutcome, CoreError>

Trait Implementations§

Source§

impl Clone for Cpu8080State

Source§

fn clone(&self) -> Cpu8080State

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Cpu8080State

Source§

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

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

impl Default for Cpu8080State

#[derive(Default)] would yield sp: 0; reference uses 0xFFFF.

Source§

fn default() -> Self

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

impl Eq for Cpu8080State

Source§

impl PartialEq for Cpu8080State

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Cpu8080State

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.