aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2026-01-04 19:18:53 +0530
committerkrolxon <krolyxon@tutanota.com>2026-01-04 19:18:53 +0530
commitd05f2980db4a3bd6cb90dae478560fc15fccb128 (patch)
tree0ac66b62b63b5c288e83c38efb648857f0ef54d5 /src/main.rs
parent6e317ee063844780961a70b13a6aea73154ad72e (diff)
add code formatting
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 24a43ae..fc7f311 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,15 +3,13 @@ mod instructions;
mod memory;
use cpu::CPU;
-use memory::Memory;
use instructions::Instruction;
+use memory::Memory;
fn main() {
let mut cpu = CPU::default();
let mut mem = Memory::new();
-
-
// a = 10
mem.write(0x0000, Instruction::MOV as u8);
mem.write(0x0001, 0);
@@ -45,17 +43,16 @@ fn main() {
cpu.inc_pc();
match opcode {
- x if x == Instruction::MOV as u8 => cpu.mov(&mut mem),
+ x if x == Instruction::MOV as u8 => cpu.mov(&mut mem),
x if x == Instruction::ADD as u8 => cpu.add(&mut mem),
x if x == Instruction::SUB as u8 => cpu.sub(&mut mem),
x if x == Instruction::JMP as u8 => cpu.jmp(&mut mem),
- x if x == Instruction::JZ as u8 => cpu.jz(&mut mem),
- x if x == Instruction::JNZ as u8 => cpu.jnz(&mut mem),
+ x if x == Instruction::JZ as u8 => cpu.jz(&mut mem),
+ x if x == Instruction::JNZ as u8 => cpu.jnz(&mut mem),
x if x == Instruction::HLT as u8 => cpu.halt(),
_ => panic!("Unknown opcode {:02X}", opcode),
}
}
println!("{:#?}", cpu);
-
}