pub struct Regs { /* private fields */ }
Expand description
Z80 registers
Implementations§
Source§impl Regs
impl Regs
pub fn get_reg_8(&self, index: RegName8) -> u8
pub fn set_reg_8(&mut self, index: RegName8, value: u8) -> u8
pub fn get_reg_16(&self, index: RegName16) -> u16
pub fn set_reg_16(&mut self, index: RegName16, value: u16) -> u16
pub fn inc_reg_8(&mut self, reg: RegName8) -> u8
pub fn inc_reg_16(&mut self, reg: RegName16) -> u16
pub fn dec_reg_8(&mut self, reg: RegName8) -> u8
pub fn dec_reg_16(&mut self, reg: RegName16) -> u16
pub fn get_pc(&self) -> u16
pub fn set_pc(&mut self, value: u16) -> u16
pub fn inc_pc(&mut self) -> u16
pub fn set_mem_ptr(&mut self, value: u16) -> u16
pub fn get_mem_ptr(&self) -> u16
pub fn step_q(&mut self)
pub fn clear_q(&mut self)
pub fn get_last_q(&self) -> u8
pub fn dec_pc(&mut self) -> u16
Sourcepub fn shift_pc(&mut self, displacement: i8) -> u16
pub fn shift_pc(&mut self, displacement: i8) -> u16
Displaces program counter with signed value
pub fn get_af(&self) -> u16
pub fn get_bc(&self) -> u16
pub fn get_ix(&self) -> u16
pub fn get_iy(&self) -> u16
pub fn set_af(&mut self, value: u16) -> u16
pub fn set_bc(&mut self, value: u16) -> u16
pub fn get_hl(&self) -> u16
pub fn set_hl(&mut self, value: u16) -> u16
pub fn get_de(&self) -> u16
pub fn set_de(&mut self, value: u16) -> u16
pub fn set_ix(&mut self, value: u16) -> u16
pub fn set_iy(&mut self, value: u16) -> u16
pub fn inc_sp(&mut self) -> u16
pub fn dec_sp(&mut self) -> u16
pub fn get_sp(&self) -> u16
pub fn set_sp(&mut self, value: u16) -> u16
pub fn get_ir(&self) -> u16
pub fn get_acc(&self) -> u8
pub fn get_acc_alt(&self) -> u8
pub fn set_acc(&mut self, value: u8) -> u8
pub fn set_flags(&mut self, value: u8) -> u8
pub fn get_flags(&self) -> u8
pub fn get_flags_alt(&self) -> u8
pub fn get_i(&self) -> u8
pub fn set_i(&mut self, value: u8) -> u8
pub fn get_r(&self) -> u8
pub fn set_r(&mut self, value: u8) -> u8
Sourcepub fn inc_r(&mut self) -> u8
pub fn inc_r(&mut self) -> u8
Special function for incrementing only lower 7 bits of R
register
pub fn get_b(&self) -> u8
pub fn get_c(&self) -> u8
pub fn get_d(&self) -> u8
pub fn get_e(&self) -> u8
pub fn get_h(&self) -> u8
pub fn get_l(&self) -> u8
pub fn get_b_alt(&self) -> u8
pub fn get_c_alt(&self) -> u8
pub fn get_d_alt(&self) -> u8
pub fn get_e_alt(&self) -> u8
pub fn get_h_alt(&self) -> u8
pub fn get_l_alt(&self) -> u8
pub fn get_iff1(&self) -> bool
pub fn get_iff2(&self) -> bool
pub fn set_iff1(&mut self, value: bool) -> bool
pub fn set_iff2(&mut self, value: bool) -> bool
pub fn swap_af_alt(&mut self)
pub fn exx(&mut self)
Sourcepub fn update_flags_block_mem_cycle(&mut self)
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
Sourcepub fn update_flags_block_io_cycle(&mut self, opcode: BlockIoOpcode, m: u8)
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more