From 0047b7d76209e6693997e324de7110e8faf9bb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Wed, 15 Mar 2023 10:45:02 +0100 Subject: [PATCH] Fixed incorrect length and address readouts because of an incorrectly configured radix --- src/simulator/mem_cmp.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/simulator/mem_cmp.rs b/src/simulator/mem_cmp.rs index c955daf..39e8008 100644 --- a/src/simulator/mem_cmp.rs +++ b/src/simulator/mem_cmp.rs @@ -39,8 +39,8 @@ impl Section { /// Creates a memory section from a SectionFormat fn from(section: &SectionFormat) -> Section { - let addr = usize::from_str_radix(§ion.addr, 16).unwrap_or_default(); - let len = usize::from_str_radix(§ion.len, 16).unwrap_or_default(); + let addr = usize::from_str_radix(§ion.addr, 10).unwrap_or_default(); + let len = usize::from_str_radix(§ion.len, 10).unwrap_or_default(); let content: Vec = section.content.as_bytes().chunks(2).map(|x| { u8::from_str_radix(std::str::from_utf8(x).unwrap_or_default(), 16).unwrap_or_default() }).collect(); @@ -168,9 +168,7 @@ impl MemChecker{ machine.int_reg.set_reg(2, m_c.sp as i64); machine.pc = m_c.pc as u64; - for section in m_c.sections.iter() { - for (i,b) in section.content.iter().enumerate() { machine.main_memory[section.addr + i] = *b; }