iz80/
lib.rs

1//! Z80 Emulator library that passes all ZEXALL tests
2//! 
3//! See bin/cpuville.rs or the [iz-cpm](https://github.com/ivanizag/iz-cpm)
4//! project for usage examples.
5//! 
6//!# Example
7//! To run this example, execute: `cargo run --bin simplest`
8//! 
9//! ```
10//!use iz80::*;
11//!
12//!fn main() {
13//!    // Prepare the device
14//!    let mut machine = PlainMachine::new();
15//!    let mut cpu = Cpu::new(); // Or Cpu::new_8080()
16//!    cpu.set_trace(true);
17//!
18//!    // Load program inline or from a file with:
19//!    //      let code = include_bytes!("XXXX.rom");
20//!    let code = [0x3c, 0xc3, 0x00, 0x00]; // INC A, JP $0000
21//!    let size = code.len();
22//!    for i in 0..size {
23//!        machine.poke(0x0000 + i as u16, code[i]);
24//!    }
25//!
26//!    // Run emulation
27//!    cpu.registers().set_pc(0x0000);
28//!    loop {
29//!        cpu.execute_instruction(&mut machine);
30//!
31//!        // Examine machine state to update the hosting device as needed.
32//!        if cpu.registers().a() == 0x10 {
33//!            // Let's stop
34//!            break;
35//!        }
36//!    }
37//!}
38//! ```
39
40
41mod cpu;
42mod machine;
43mod registers;
44mod state;
45mod timed_runner;
46
47mod decoder_z80;
48mod decoder_8080;
49mod environment;
50mod opcode;
51mod opcode_alu;
52mod opcode_arith;
53mod opcode_bits;
54mod opcode_io;
55mod opcode_jumps;
56mod opcode_ld;
57mod operators;
58
59pub use cpu::Cpu;
60pub use machine::Machine;
61pub use machine::PlainMachine;
62pub use registers::*;
63pub use timed_runner::TimedRunner;