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: u16Accumulator (full 16 bits stored; the active width is the M flag).
x: u16X index register (full 16 bits stored; the active width is the X flag).
y: u16Y index register (full 16 bits stored; the active width is the X flag).
s: u16Stack pointer (16-bit in native mode; forced to page $01 in emulation mode).
d: u16Direct-page register D.
dbr: u8Data bank register DBR.
pbr: u8Program bank register PBR / K.
pc: u16Program counter (16-bit; bank is pbr).
p: StatusProcessor status flags P.
emulation: boolHidden emulation-mode latch E (true at power-on).
Implementations§
Source§impl Regs
impl Regs
Sourcepub const fn new() -> Self
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.
Sourcepub const fn m8(&self) -> bool
pub const fn m8(&self) -> bool
Whether the accumulator / memory width is 8-bit (M flag set, or emulation mode).
Sourcepub const fn x8(&self) -> bool
pub const fn x8(&self) -> bool
Whether the index registers are 8-bit (X flag set, or emulation mode).
Sourcepub const fn a_val(&self) -> u16
pub const fn a_val(&self) -> u16
Read the accumulator at the active width (high byte masked off when 8-bit).
Sourcepub const fn set_a(&mut self, val: u16)
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.
Sourcepub const fn set_x(&mut self, val: u16)
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).