4-bit virtual CPU
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
528 B

// SPDX-License-Identifier: MIT
// Copyright Murad Karammaev, Nikita Kuzmin
mod assembler;
mod cpu;
mod instruction;
use assembler::Assembler;
use cpu::*;
fn main() {
let asm = Assembler::new();
let code = asm
.assemble(
r#"
MOV R0.h, 0x0
MOV R0.l, 0xF
MOV R1.l, 0x3
ADD
MOV [0], R0
ZERO R0
HALT
"#,
)
.unwrap();
let mut cpu = Cpu::new(&code);
loop {
if cpu.step() {
break;
}
}
cpu.visualize();
}