-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create the main execution loop for the virtual machine.
Create the main execution loop for the virtual machine.
- Loading branch information
Showing
2 changed files
with
140 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
// src/main.rs | ||
|
||
mod cpu; | ||
mod io; | ||
mod memory; | ||
|
||
use cpu::CPU; | ||
use io::IOController; | ||
use memory::MemoryManagementUnit; | ||
|
||
fn main() { | ||
println!("Virtual Machine Initializing..."); | ||
let io_controller = IOController::new(); | ||
let mut cpu = CPU::new(io_controller); | ||
let mmu = MemoryManagementUnit::new(); | ||
let mut cpu = CPU::new(io_controller, mmu); | ||
|
||
// Load a simple program into memory | ||
let program = vec![ | ||
0x46, 0x00, // INPUT R0 | ||
0x47, 0x01, // OUTPUT R1 | ||
0x40, 0x10, // ADD R1, R0 | ||
0x47, 0x01, // OUTPUT R1 | ||
0x4E, 0x00, // CMP R0, R0 | ||
0x50, 0x00, // JE 0 (Loop back to start) | ||
]; | ||
|
||
cpu.load_program(&program); | ||
cpu.run(); | ||
} |