squelette Mem_Checker

This commit is contained in:
Moysan Gabriel 2023-02-07 22:50:55 +01:00
parent 8adee1b42b
commit 70210699a4

View File

@ -37,34 +37,6 @@ struct Section{
content: Vec<u8>, // 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<Section>,
}
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;