An emulator for the LC2 ISA 🤖
-
Add the library to you project:
cargo add architectures --git https://git.nicolabelluti.me/little-emulator/little-emulator.git
-
Use the emulator in you project:
use architectures::{lc2::Lc2, Architecture, WatcherType}; fn main() { // Create a new LC2 let mut cpu = Lc2::new(0x3000); // Setup the Machine Control Register cpu.set_memory(0xffff, 0x8000); // Add the memory watcher for the Video Data Register cpu.add_memory_watcher(0xf3ff, WatcherType::OnWrite, |x| { print!("{}", char::from_u32(x as u32).unwrap()); }); // Load the program cpu.load_bytes(0x3000, &[ 0xe2, 0x0a, 0x60, 0x40, 0x04, 0x06, 0xb0, 0x08, 0x12, 0x61, 0x40, 0x01, 0x50, 0x20, 0xb0, 0x09, 0xf3, 0xff, 0xff, 0xff, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x2c, 0x00, 0x20, 0x00, 0x57, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6c, 0x00, 0x64, 0x00, 0x21, 0x00, 0x0a, 0x00, 0x00, ]).unwrap(); // Run the program while cpu.get_memory(0xffff) & 0x8000 != 0 { cpu.step_instruction(); } }