intel_8080_emu/lib.rs
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5//! # Intel 8080 emulator
6//!
7//! This crates aims to be a flexible library to embed a 8080 emulator. It is currently used
8//! to run a space invaders emulator but could be used for others emulators.
9//!
10//! The main struct is [`Proc8080`](proc_state/struct.Proc8080.html) which emulates the state
11//! of a 8080 processor (memory, flags and registers).
12//!
13//! The second useful construct is probably the function
14//! [`read_opcode`](opcode/fn.read_opcode.html) which can be used to build a disassembler backed
15//! by this crate [opcode implementation](opcode/enum.OpCode.html).
16//!
17//! Here is an example of such a disassembler :
18//!
19//! ```no_run
20//! extern crate intel_8080_emu;
21//!
22//! use std::fs::File;
23//! use std::io;
24//! use intel_8080_emu::opcode::OpCodes;
25//!
26//! fn main() {
27//! let file_path: Option<String> = std::env::args().skip(1).next();
28//! match file_path {
29//! None => {
30//! eprintln!("usage: disassembler <file>");
31//! std::process::exit(1);
32//! }
33//! Some(path) => {
34//! let input: File = File::open(path).expect("file not found");
35//! let op_codes = OpCodes::new(io::BufReader::new(input));
36//! let mut count = 0;
37//! for op_code_result in op_codes {
38//! let op_code = op_code_result.unwrap();
39//! println!("0x{:04x?} - {}", count, op_code);
40//! count += op_code.size();
41//! }
42//! }
43//! }
44//! }
45//! ```
46
47
48pub mod proc_state;
49pub mod opcode;