This commit is contained in:
Moysan Gabriel 2022-11-16 16:52:52 +01:00
parent 9a233f3c12
commit 98f4c0b67e
2 changed files with 3 additions and 4 deletions

View File

@ -27,14 +27,14 @@ impl Machine {
} }
} }
pub fn one_instruction(mut machine : Machine) -> Machine { pub fn one_instruction(machine :&mut Machine) {
let mut unsigned_reg1 : u64 = 0; let mut unsigned_reg1 : u64 = 0;
let mut unsigned_reg2 : u64 = 0; let mut unsigned_reg2 : u64 = 0;
if machine.instructions.len() <= machine.pc as usize { if machine.instructions.len() <= machine.pc as usize {
println!("ERROR : number max of instructions rushed"); println!("ERROR : number max of instructions rushed");
return machine; return ;
} }
let inst : Instruction = decode(machine.instructions[machine.pc as usize]); let inst : Instruction = decode(machine.instructions[machine.pc as usize]);
@ -128,7 +128,6 @@ impl Machine {
} }
machine
} }
} }

View File

@ -6,5 +6,5 @@ use machine::Machine;
fn main() { fn main() {
let mut m = Machine::_init_machine(); let mut m = Machine::_init_machine();
m.instructions[0] = 0x37; m.instructions[0] = 0x37;
Machine::one_instruction(m); Machine::one_instruction(&mut m);
} }