machine tests ok
This commit is contained in:
parent
84d8bcc84f
commit
2533883ea7
@ -39,7 +39,7 @@ pub const NUM_PHY_PAGE : u64 = 400;
|
||||
//doit etre une puissance de deux
|
||||
pub const PAGE_SIZE : u64 = 128;
|
||||
//doit etre un multiple de PAGE_SIZE
|
||||
pub const MEM_SIZE : usize = (PAGE_SIZE*NUM_PHY_PAGE) as usize;
|
||||
pub const MEM_SIZE : usize = (PAGE_SIZE*NUM_PHY_PAGE*100) as usize;
|
||||
|
||||
|
||||
pub trait RegisterNum: Add<Output=Self> + Sub<Output=Self> + PartialEq + Copy {}
|
||||
@ -257,8 +257,8 @@ impl Machine {
|
||||
panic!("ERROR : number max of instructions rushed");
|
||||
}
|
||||
let mut val: [u8; 4] = [0; 4];
|
||||
for (i, mut _item) in val.iter_mut().enumerate() {
|
||||
_item = &mut machine.main_memory[machine.pc as usize + i];
|
||||
for i in 0..4 {
|
||||
val[i] = machine.main_memory[machine.pc as usize + i];
|
||||
}
|
||||
|
||||
let val = u32::from_be_bytes(val) as u64;
|
||||
@ -763,6 +763,8 @@ mod test {
|
||||
let memory_before = mem_cmp::MemChecker::from("test/machine/memoryComp.txt").unwrap();
|
||||
let memory_after = mem_cmp::MemChecker::from("test/machine/memoryCompEnd.txt").unwrap();
|
||||
mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m);
|
||||
Machine::_print_memory(&mut m, 0x4000, 0x4200);
|
||||
Machine::_print_memory(&mut m, 4000, 4200);
|
||||
Machine::run(&mut m);
|
||||
|
||||
let expected_trace = fs::read_to_string("test/machine/reg_traceComp.txt").unwrap();
|
||||
@ -772,7 +774,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
//#[ignore]
|
||||
fn test_div() {
|
||||
let mut m = Machine::init_machine();
|
||||
let memory_before = mem_cmp::MemChecker::from("test/machine/memoryDiv.txt").unwrap();
|
||||
@ -787,7 +789,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
//#[ignore]
|
||||
fn test_if() {
|
||||
let mut m = Machine::init_machine();
|
||||
let memory_before = mem_cmp::MemChecker::from("test/machine/memoryIf.txt").unwrap();
|
||||
@ -802,7 +804,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
//#[ignore]
|
||||
fn test_jump() {
|
||||
let mut m = Machine::init_machine();
|
||||
let memory_before = mem_cmp::MemChecker::from("test/machine/memoryJump.txt").unwrap();
|
||||
@ -817,7 +819,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
//#[ignore]
|
||||
fn test_mul() {
|
||||
let mut m = Machine::init_machine();
|
||||
let memory_before = mem_cmp::MemChecker::from("test/machine/memoryMult.txt").unwrap();
|
||||
@ -832,7 +834,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
//#[ignore]
|
||||
fn test_ret() {
|
||||
let mut m = Machine::init_machine();
|
||||
let memory_before = mem_cmp::MemChecker::from("test/machine/memoryRet.txt").unwrap();
|
||||
@ -847,7 +849,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
//#[ignore]
|
||||
fn test_sub() {
|
||||
let mut m = Machine::init_machine();
|
||||
let memory_before = mem_cmp::MemChecker::from("test/machine/memorySub.txt").unwrap();
|
||||
@ -862,7 +864,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
//#[ignore]
|
||||
fn test_switch() {
|
||||
let mut m = Machine::init_machine();
|
||||
let memory_before = mem_cmp::MemChecker::from("test/machine/memorySwitch.txt").unwrap();
|
||||
|
@ -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, 10).unwrap_or_default();
|
||||
let len = usize::from_str_radix(§ion.len, 10).unwrap_or_default();
|
||||
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 content: Vec<u8> = 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();
|
||||
@ -170,7 +170,7 @@ impl MemChecker{
|
||||
|
||||
for section in m_c.sections.iter() {
|
||||
for (i,b) in section.content.iter().enumerate() {
|
||||
machine.main_memory[section.addr/8 + i] = *b;
|
||||
machine.main_memory[section.addr + i] = *b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user