Struct CPU

Source
pub struct CPU {
    pub reg: Registers,
    pub halt: bool,
    pub iff1: bool,
    pub iff2: bool,
    pub invalid_op: bool,
    pub mem: Memory,
    /* private fields */
}
Expand description

Z80 CPU emulation

Fields§

§reg: Registers§halt: bool§iff1: bool§iff2: bool§invalid_op: bool§mem: Memory

Implementations§

Source§

impl CPU

Source

pub fn new() -> CPU

initialize a new Z80 CPU object

Source

pub fn new_64k() -> CPU

initialize a new CPU object with 64K RAM (for testing)

Source

pub fn reset(&mut self)

reset the cpu

Source

pub fn step(&mut self, bus: &dyn Bus) -> i64

decode and execute one instruction

Source

pub fn do_op(&mut self, bus: &dyn Bus, ext: bool) -> i64

execute a single ‘main-instruction’

This function may be called recursively for prefixed instructions

  • ‘m’ - index of 16-bit register (may be HL, IX or IY)
  • ‘d’ - the d in (IX+d), (IY+d), 0 if m is HL

returns number of cycles the instruction takes

Source

pub fn irq(&mut self)

Source

pub fn reti(&mut self, bus: &dyn Bus) -> i64

Source

pub fn handle_irq(&mut self, bus: &dyn Bus) -> i64

Source

pub fn halt(&mut self)

Source

pub fn push(&mut self, val: RegT)

Source

pub fn pop(&mut self) -> RegT

Source

pub fn rst(&mut self, val: RegT)

Source

pub fn alu8(&mut self, alu: usize, val: RegT)

Source

pub fn add8(&mut self, add: RegT)

Source

pub fn adc8(&mut self, add: RegT)

Source

pub fn sub8(&mut self, sub: RegT)

Source

pub fn sbc8(&mut self, sub: RegT)

Source

pub fn cp8(&mut self, sub: RegT)

Source

pub fn neg8(&mut self)

Source

pub fn and8(&mut self, val: RegT)

Source

pub fn or8(&mut self, val: RegT)

Source

pub fn xor8(&mut self, val: RegT)

Source

pub fn inc8(&mut self, val: RegT) -> RegT

Source

pub fn dec8(&mut self, val: RegT) -> RegT

Source

pub fn rot(&mut self, op: usize, val: RegT) -> RegT

Source

pub fn rlc8(&mut self, val: RegT) -> RegT

Source

pub fn rlca8(&mut self)

Source

pub fn rrc8(&mut self, val: RegT) -> RegT

Source

pub fn rrca8(&mut self)

Source

pub fn rl8(&mut self, val: RegT) -> RegT

Source

pub fn rla8(&mut self)

Source

pub fn rr8(&mut self, val: RegT) -> RegT

Source

pub fn rra8(&mut self)

Source

pub fn sla8(&mut self, val: RegT) -> RegT

Source

pub fn sll8(&mut self, val: RegT) -> RegT

Source

pub fn sra8(&mut self, val: RegT) -> RegT

Source

pub fn srl8(&mut self, val: RegT) -> RegT

Source

pub fn rld(&mut self)

Source

pub fn rrd(&mut self)

Source

pub fn bit(&mut self, val: RegT, mask: RegT)

Source

pub fn ibit(&mut self, val: RegT, mask: RegT)

Source

pub fn add16(&mut self, acc: RegT, add: RegT) -> RegT

Source

pub fn adc16(&mut self, acc: RegT, add: RegT) -> RegT

Source

pub fn sbc16(&mut self, acc: RegT, sub: RegT) -> RegT

Source

pub fn djnz(&mut self) -> i64

Source

pub fn daa(&mut self)

Source

pub fn cpl(&mut self)

Source

pub fn scf(&mut self)

Source

pub fn ccf(&mut self)

Source

pub fn ret(&mut self) -> i64

Source

pub fn call(&mut self) -> i64

Source

pub fn retcc(&mut self, y: usize) -> i64

Source

pub fn callcc(&mut self, y: usize) -> i64

Source

pub fn ldi(&mut self)

Source

pub fn ldd(&mut self)

Source

pub fn ldir(&mut self) -> i64

Source

pub fn lddr(&mut self) -> i64

Source

pub fn cpi(&mut self)

Source

pub fn cpd(&mut self)

Source

pub fn cpir(&mut self) -> i64

Source

pub fn cpdr(&mut self) -> i64

Source

pub fn inp(&mut self, bus: &dyn Bus, port: RegT) -> RegT

Source

pub fn outp(&mut self, bus: &dyn Bus, port: RegT, val: RegT)

Source

pub fn ini(&mut self, bus: &dyn Bus)

Source

pub fn ind(&mut self, bus: &dyn Bus)

Source

pub fn inir(&mut self, bus: &dyn Bus) -> i64

Source

pub fn indr(&mut self, bus: &dyn Bus) -> i64

Source

pub fn outi(&mut self, bus: &dyn Bus)

Source

pub fn outd(&mut self, bus: &dyn Bus)

Source

pub fn otir(&mut self, bus: &dyn Bus) -> i64

Source

pub fn otdr(&mut self, bus: &dyn Bus) -> i64

Auto Trait Implementations§

§

impl Freeze for CPU

§

impl RefUnwindSafe for CPU

§

impl Send for CPU

§

impl Sync for CPU

§

impl Unpin for CPU

§

impl UnwindSafe for CPU

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.