Skip to main content

Regs

Struct Regs 

Source
pub struct Regs {
    pub a: u16,
    pub x: u16,
    pub y: u16,
    pub s: u16,
    pub d: u16,
    pub dbr: u8,
    pub pbr: u8,
    pub pc: u16,
    pub p: Status,
    pub emulation: bool,
}
Expand description

The complete architectural register file of the 65C816.

Fields§

§a: u16

Accumulator (full 16 bits stored; the active width is the M flag).

§x: u16

X index register (full 16 bits stored; the active width is the X flag).

§y: u16

Y index register (full 16 bits stored; the active width is the X flag).

§s: u16

Stack pointer (16-bit in native mode; forced to page $01 in emulation mode).

§d: u16

Direct-page register D.

§dbr: u8

Data bank register DBR.

§pbr: u8

Program bank register PBR / K.

§pc: u16

Program counter (16-bit; bank is pbr).

§p: Status

Processor status flags P.

§emulation: bool

Hidden emulation-mode latch E (true at power-on).

Implementations§

Source§

impl Regs

Source

pub const fn new() -> Self

Power-on register file: emulation mode (E=1), M=1, X=1, I=1, D=0, with the stack pointer parked at $01FF. PC is loaded from the reset vector by crate::Cpu::reset.

Source

pub const fn m8(&self) -> bool

Whether the accumulator / memory width is 8-bit (M flag set, or emulation mode).

Source

pub const fn x8(&self) -> bool

Whether the index registers are 8-bit (X flag set, or emulation mode).

Source

pub const fn a_val(&self) -> u16

Read the accumulator at the active width (high byte masked off when 8-bit).

Source

pub const fn set_a(&mut self, val: u16)

Write the accumulator at the active width, preserving the hidden high byte (B) when in 8-bit mode — matching hardware, where A and B are distinct halves.

Source

pub const fn x_val(&self) -> u16

Read X at the active index width.

Source

pub const fn y_val(&self) -> u16

Read Y at the active index width.

Source

pub const fn set_x(&mut self, val: u16)

Write X; in 8-bit index mode the high byte is forced to zero (hardware behavior).

Source

pub const fn set_y(&mut self, val: u16)

Write Y; in 8-bit index mode the high byte is forced to zero (hardware behavior).

Source

pub const fn set_nz_m(&mut self, val: u16)

Update N and Z from an accumulator-width result.

Source

pub const fn set_nz_x(&mut self, val: u16)

Update N and Z from an index-width result.

Source

pub const fn set_nz8(&mut self, val: u8)

Update N/Z from an explicit 8-bit value.

Source

pub const fn set_nz16(&mut self, val: u16)

Update N/Z from an explicit 16-bit value.

Source

pub const fn set_flag(&mut self, flag: Status, on: bool)

Set or clear a single status flag.

Trait Implementations§

Source§

impl Clone for Regs

Source§

fn clone(&self) -> Regs

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 Regs

Source§

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

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

impl Default for Regs

Source§

fn default() -> Self

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

impl PartialEq for Regs

Source§

fn eq(&self, other: &Regs) -> 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 Regs

Source§

impl Eq for Regs

Source§

impl StructuralPartialEq for Regs

Auto Trait Implementations§

§

impl Freeze for Regs

§

impl RefUnwindSafe for Regs

§

impl Send for Regs

§

impl Sync for Regs

§

impl Unpin for Regs

§

impl UnsafeUnpin for Regs

§

impl UnwindSafe for Regs

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.