1
0
forked from Rativel/BurritOS

change memory to a vector, it can now be fill

This commit is contained in:
Baptiste
2023-03-01 16:12:46 +01:00
parent e82af4ae67
commit 5a90419ebb
4 changed files with 27 additions and 37 deletions

View File

@@ -106,7 +106,7 @@ impl Mem_Checker{
pub fn from(path: &String) -> Mem_Checker {
let file = fs::File::open("test_file_section.txt").expect("Wrong filename");
let file = fs::File::open(path).expect("Wrong filename");
let reader = io::BufReader::new(file);
let mut lines = reader.lines();
@@ -124,7 +124,7 @@ impl Mem_Checker{
let current_line = vector.get(i).unwrap_or(&default);
//Lecture des sections
if current_line.contains(' ') {
if i % 2 == 0 {
//lecture ligne ADDR LEN
let next_word_index = current_line.find(' ').unwrap();
tmp_addr_str = String::from(&current_line[0..next_word_index]);
@@ -135,7 +135,7 @@ impl Mem_Checker{
let section_f = SectionFormat{
addr: tmp_addr_str.clone(),
len: tmp_len_str.clone(),
content: current_line.clone(),
content: current_line.clone().replace(" ", ""),
};
sections.push(Section::from(&section_f));
}
@@ -147,8 +147,8 @@ impl Mem_Checker{
pub fn print_Mem_Checker(m_c: &Mem_Checker){
println!("PC :: {}", m_c.pc);
println!("SP :: {}", m_c.sp);
println!("PC :: {:x}", m_c.pc);
println!("SP :: {:x}", m_c.sp);
for(i,s) in m_c.sections.iter().enumerate() {
println!("\nSection {}\n", i);