Crate intel_8080_emu
source ·Expand description
Intel 8080 emulator
This crates aims to be a flexible library to embed a 8080 emulator. It is currently used to run a space invaders emulator but could be used for others emulators.
The main struct is Proc8080
which emulates the state
of a 8080 processor (memory, flags and registers).
The second useful construct is probably the function
read_opcode
which can be used to build a disassembler backed
by this crate opcode implementation.
Here is an example of such a disassembler :
extern crate intel_8080_emu;
use std::fs::File;
use std::io;
use intel_8080_emu::opcode::OpCodes;
fn main() {
let file_path: Option<String> = std::env::args().skip(1).next();
match file_path {
None => {
eprintln!("usage: disassembler <file>");
std::process::exit(1);
}
Some(path) => {
let input: File = File::open(path).expect("file not found");
let op_codes = OpCodes::new(io::BufReader::new(input));
let mut count = 0;
for op_code_result in op_codes {
let op_code = op_code_result.unwrap();
println!("0x{:04x?} - {}", count, op_code);
count += op_code.size();
}
}
}
}