From 3269fa353f6057dc1153017ce6ab486b1a19831b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rativel?= Date: Mon, 13 Feb 2023 11:08:24 +0100 Subject: [PATCH] Implemented extract_memory --- src/simulator/machine.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/simulator/machine.rs b/src/simulator/machine.rs index dbd18bb..f3f635b 100644 --- a/src/simulator/machine.rs +++ b/src/simulator/machine.rs @@ -1,7 +1,8 @@ -use std::ops::{Add, Sub}; +use std::{ops::{Add, Sub}, io::Write}; use super::{decode::{Instruction, decode}}; use super::global::*; +use std::fs::File; /// doit disparaitre const MEM_SIZE : usize = 4096; @@ -136,6 +137,17 @@ impl Machine { } } + /// Write the contains of the main memory of the machine + /// in a file called burritos_memory.txt + /// + /// ### Parameters + /// + /// - **machine** contains the memory + pub fn extract_memory(machine: &mut Machine){ + let mut file = File::create("burritos_memory.txt").unwrap(); + file.write(&machine.main_memory); + } + /// Execute the instructions table of a machine putted in param /// /// ### Parameters