From 4425ac747e650fe4cb3ae03865160cb5f09123b1 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Wed, 15 Feb 2023 15:45:37 +0100 Subject: [PATCH] debuging mem_checker::from --- src/simulator/mem_cmp.rs | 12 +++++---- test_file_section.txt | 23 ++++++++++++------ .../simple_arithmerics/unsigned_addition.o | Bin 0 -> 1088 bytes 3 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 test_programs/riscv_instructions/simple_arithmerics/unsigned_addition.o diff --git a/src/simulator/mem_cmp.rs b/src/simulator/mem_cmp.rs index abddae9..c4a8a5a 100644 --- a/src/simulator/mem_cmp.rs +++ b/src/simulator/mem_cmp.rs @@ -94,7 +94,10 @@ impl Mem_Checker{ fn from(path: &String) -> Mem_Checker { let file = fs::File::open("test_file_section.txt").expect("Wrong filename"); - let reader = io::BufReader::new(file); + let reader = io::BufReader::new(&file); + let reader2 = io::BufReader::new(&file); + let lines = reader.lines(); + let length = reader2.lines().count(); let mut pc: usize = 0; let mut sp: usize = 0; @@ -103,15 +106,15 @@ impl Mem_Checker{ let mut tmp_addr_str: String = String::new(); let mut tmp_len_str: String = String::new(); - for (i,line) in reader.lines().enumerate() { + for (i,line) in lines.enumerate() { let current_line = line.unwrap(); - if i == current_line.len()-2 { + if i == length-2 { //Lecture de PC pc = string_hex_to_usize(¤t_line); } - else if i == current_line.len()-1 { + else if i == length-1 { //Lecture SP sp = string_hex_to_usize(¤t_line); } @@ -277,7 +280,6 @@ mod tests { } - #[test] fn test_enum_start_at_zero(){ let v = vec![1,2,3]; diff --git a/test_file_section.txt b/test_file_section.txt index 05d3ead..df1b0d2 100644 --- a/test_file_section.txt +++ b/test_file_section.txt @@ -1,8 +1,15 @@ -0 -0 -FF FF -F4A12200 -A0 0A -01022B -0B 0F -FFACBC5CEF +addi sp,sp,-32 +sd s0,24(sp) +addi s0,sp,32 +sw zero,-20(s0) +li a5,1 +sw a5,-24(s0) +lw a5,-20(s0) +mv a4,a5 +lw a5,-24(s0) +addw a5,a4,a5 +sw a5,-20(s0) +nop +ld s0,24(sp) +addi sp,sp,32 +ret \ No newline at end of file diff --git a/test_programs/riscv_instructions/simple_arithmerics/unsigned_addition.o b/test_programs/riscv_instructions/simple_arithmerics/unsigned_addition.o new file mode 100644 index 0000000000000000000000000000000000000000..3d69445f952a67be3ab705cbfff4767457813b8b GIT binary patch literal 1088 zcmbtTPfG$(5TE^H>dlfOs6bJ)ARen}M0hZyy!0Jp)y4L(tGG`w2uck40A2hdow{`B zL-aKwq1)CxdoLd^>EgidZ{|1id-G=4y*g?AqtcHefS*xgiLN0CQ)aU#u{q$&K(BzTJ1Eo-zhpy z*(n`aR^j9zRVb1ovEVF)`Mw*phM;YsYbGN7;c>|=_N<17FQoo8HiHT8U(1S&F4UDh7Vwc6_JZu-k2yx?P{NAUgujc6|U6 zTzk}RBGUd3UI~vnBMPK#QyWM#2!OP@p6B?;&9_NxO8aheK%GEzS_yYh&9<szKHD3M2@Ol;0jpwl-wu1f;wd_pwgA)CBF(;eoFR+YByn9csVg8g8X(b_a zf@ZPwYY7@&xc9~}ipb_<4>R`NFpJ}(?vC+O-e`{nlBxaIF}FpF literal 0 HcmV?d00001