From 98f4c0b67eca10add21d2821b1bd0d9066c6c98d Mon Sep 17 00:00:00 2001 From: Moysan Gabriel Date: Wed, 16 Nov 2022 16:52:52 +0100 Subject: [PATCH] base --- src/machine.rs | 5 ++--- src/main.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index 22a6b7a..2bb70f7 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -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_reg2 : u64 = 0; if machine.instructions.len() <= machine.pc as usize { println!("ERROR : number max of instructions rushed"); - return machine; + return ; } let inst : Instruction = decode(machine.instructions[machine.pc as usize]); @@ -128,7 +128,6 @@ impl Machine { } - machine } } diff --git a/src/main.rs b/src/main.rs index 5f265bb..8a37ccd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,5 +6,5 @@ use machine::Machine; fn main() { let mut m = Machine::_init_machine(); m.instructions[0] = 0x37; - Machine::one_instruction(m); + Machine::one_instruction(&mut m); }