diff --git a/src/simulator/mem_cmp.rs b/src/simulator/mem_cmp.rs index 41bcf3a..859bfad 100644 --- a/src/simulator/mem_cmp.rs +++ b/src/simulator/mem_cmp.rs @@ -37,34 +37,6 @@ struct Section{ content: Vec, // la donnée en question } -/* -* c doit etre un caractère hexadécimale - */ -fn one_hex_to_dec(c: char) -> u8 { - - match c { - 'A' | 'a' => 10, - 'B' | 'b' => 11, - 'C' | 'c' => 12, - 'D' | 'd' => 13, - 'E' | 'e' => 14, - 'F' | 'f' => 15, - _ => { - let ret : u8 = c.to_digit(10).unwrap() as u8; - return ret; - }, - } - } - - - -fn two_hex_to_u8(c1: char, c2: char) -> u8 { - let a = one_hex_to_dec(c1); - let b = one_hex_to_dec(c2); - - 16*a + b -} - /* * Voir si instanciation d'une structure deplace les valeurs "locales" à la méthode from, je sais plus .... */ @@ -93,6 +65,51 @@ impl Section{ } } +/* +* Representation de l'etat de la mémoire (apres execution.... a confirmer), sous forme de sections +*/ +struct Mem_Checker{ + pc: usize, + sp: usize, + sections: Vec
, +} + + +impl Mem_Checker{ + /*fn from(path: &String) -> Mem_Checker{ + + }*/ +} + + +/* +* c doit etre un caractère hexadécimale + */ +fn one_hex_to_dec(c: char) -> u8 { + + match c { + 'A' | 'a' => 10, + 'B' | 'b' => 11, + 'C' | 'c' => 12, + 'D' | 'd' => 13, + 'E' | 'e' => 14, + 'F' | 'f' => 15, + _ => { + let ret : u8 = c.to_digit(10).unwrap() as u8; + return ret; + }, + } + } + + + +fn two_hex_to_u8(c1: char, c2: char) -> u8 { + let a = one_hex_to_dec(c1); + let b = one_hex_to_dec(c2); + + 16*a + b +} + #[cfg(test)] mod tests { use super::*; @@ -119,6 +136,11 @@ mod tests { assert_eq!(section.content, expected_vec); } + + + + + #[test] fn test_mod(){ let cond = (0%2) == 0;