Regs

Struct Regs 

Source
pub struct Regs { /* private fields */ }
Expand description

Z80 registers

Implementations§

Source§

impl Regs

Source

pub fn get_reg_8(&self, index: RegName8) -> u8

Source

pub fn set_reg_8(&mut self, index: RegName8, value: u8) -> u8

Source

pub fn get_reg_16(&self, index: RegName16) -> u16

Source

pub fn set_reg_16(&mut self, index: RegName16, value: u16) -> u16

Source

pub fn inc_reg_8(&mut self, reg: RegName8) -> u8

Source

pub fn inc_reg_16(&mut self, reg: RegName16) -> u16

Source

pub fn dec_reg_8(&mut self, reg: RegName8) -> u8

Source

pub fn dec_reg_16(&mut self, reg: RegName16) -> u16

Source

pub fn get_pc(&self) -> u16

Source

pub fn set_pc(&mut self, value: u16) -> u16

Source

pub fn inc_pc(&mut self) -> u16

Source

pub fn set_mem_ptr(&mut self, value: u16) -> u16

Source

pub fn get_mem_ptr(&self) -> u16

Source

pub fn step_q(&mut self)

Source

pub fn clear_q(&mut self)

Source

pub fn get_last_q(&self) -> u8

Source

pub fn dec_pc(&mut self) -> u16

Source

pub fn shift_pc(&mut self, displacement: i8) -> u16

Displaces program counter with signed value

Source

pub fn get_af(&self) -> u16

Source

pub fn get_bc(&self) -> u16

Source

pub fn get_ix(&self) -> u16

Source

pub fn get_iy(&self) -> u16

Source

pub fn set_af(&mut self, value: u16) -> u16

Source

pub fn set_bc(&mut self, value: u16) -> u16

Source

pub fn get_hl(&self) -> u16

Source

pub fn set_hl(&mut self, value: u16) -> u16

Source

pub fn get_de(&self) -> u16

Source

pub fn set_de(&mut self, value: u16) -> u16

Source

pub fn set_ix(&mut self, value: u16) -> u16

Source

pub fn set_iy(&mut self, value: u16) -> u16

Source

pub fn inc_sp(&mut self) -> u16

Source

pub fn dec_sp(&mut self) -> u16

Source

pub fn get_sp(&self) -> u16

Source

pub fn set_sp(&mut self, value: u16) -> u16

Source

pub fn get_ir(&self) -> u16

Source

pub fn get_acc(&self) -> u8

Source

pub fn get_acc_alt(&self) -> u8

Source

pub fn set_acc(&mut self, value: u8) -> u8

Source

pub fn set_flags(&mut self, value: u8) -> u8

Source

pub fn get_flags(&self) -> u8

Source

pub fn get_flags_alt(&self) -> u8

Source

pub fn get_i(&self) -> u8

Source

pub fn set_i(&mut self, value: u8) -> u8

Source

pub fn get_r(&self) -> u8

Source

pub fn set_r(&mut self, value: u8) -> u8

Source

pub fn inc_r(&mut self) -> u8

Special function for incrementing only lower 7 bits of R register

Source

pub fn get_b(&self) -> u8

Source

pub fn get_c(&self) -> u8

Source

pub fn get_d(&self) -> u8

Source

pub fn get_e(&self) -> u8

Source

pub fn get_h(&self) -> u8

Source

pub fn get_l(&self) -> u8

Source

pub fn get_b_alt(&self) -> u8

Source

pub fn get_c_alt(&self) -> u8

Source

pub fn get_d_alt(&self) -> u8

Source

pub fn get_e_alt(&self) -> u8

Source

pub fn get_h_alt(&self) -> u8

Source

pub fn get_l_alt(&self) -> u8

Source

pub fn get_iff1(&self) -> bool

Source

pub fn get_iff2(&self) -> bool

Source

pub fn set_iff1(&mut self, value: bool) -> bool

Source

pub fn set_iff2(&mut self, value: bool) -> bool

Source

pub fn swap_af_alt(&mut self)

Source

pub fn exx(&mut self)

Source

pub fn update_flags_block_mem_cycle(&mut self)

Sets F3 and F5 flags to 11th and and 15th bit of PC respectively. This obscurity is used by block memory operations when performing repeated execution cycle

Source

pub fn update_flags_block_io_cycle(&mut self, opcode: BlockIoOpcode, m: u8)

Obscure logic for changing flags after block io opcode iteration, which changes F3, F5, HF and PV.

Implementation was derived based on the following research: https://github.com/MrKWatkins/ZXSpectrumNextTests/tree/develop/Tests/ZX48_ZX128/Z80BlockInstructionFlags

§Original calculation algorithm:

M is the value written to or read from the I/O port == (HL), Co/Lo/Bo are “output” values of registers C/L/B

if instruction == INIR
    T = M + ((Co + 1) & 0xFF)
else if instruction == INDR
    T = M + ((Co - 1) & 0xFF)
    WARNING: to verify the "& 0xFF" part (ie. bit-width of (C-1) intermediate) one would
    need to read value 00 from port 00, which is not possible on regular ZX machine with
    common peripherals -> giving up.
else if (instruction == OTIR) || (instruction == OTDR)
    T = M + Lo

TMP = Bo + (NF ? -CF : CF);
HF = (TMP ^ Bo).4;
PV = ((T & 7) ^ Bo ^ (TMP & 7)).parity
§RustZX notes

RustZX code improves further, removing need for ternary operator during TMP calculation

Trait Implementations§

Source§

impl Default for Regs

Source§

fn default() -> Regs

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

Auto Trait Implementations§

§

impl Freeze for Regs

§

impl RefUnwindSafe for Regs

§

impl Send for Regs

§

impl Sync for Regs

§

impl Unpin 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> 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.