simplest8080/simplest8080.rs
1use iz80::{Cpu, Machine, PlainMachine};
2
3fn main() {
4 // Prepare the device
5 let mut machine = PlainMachine::new();
6 let mut cpu = Cpu::new_8080();
7 cpu.set_trace(true);
8
9 // Load program inline or from a file with:
10 // let code = include_bytes!("XXXX.rom");
11 let code = [0x3c, 0xc3, 0x00, 0x00]; // INC A, JP $0000
12 for (i, e) in code.iter().enumerate() {
13 machine.poke(i as u16, *e);
14 }
15
16 // Run emulation
17 cpu.registers().set_pc(0x0000);
18 loop {
19 cpu.execute_instruction(&mut machine);
20
21 // Examine machine state to update the hosting device as needed.
22 if cpu.registers().a() == 0x10 {
23 // Let's stop
24 break;
25 }
26 }
27}