Skip to content

Commit

Permalink
Full log
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Aug 19, 2024
1 parent fd22e30 commit c3f6e17
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/instructions/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,25 @@ pub fn execute_instruction<Mac: Machine>(
)
}

fn mem_checksum<T: Memory>(m: &mut T) -> u8 {
let mut s = 0u8;
for i in m.load_bytes(0, 4 * 1024 * 1024).unwrap().to_vec() {
s = s.wrapping_add(i);
}
return s;
}

pub fn execute<Mac: Machine>(inst: Instruction, machine: &mut Mac) -> Result<(), Error> {
println!(
"{:?} {:?} {:?}",
machine.pc().to_u64(),
machine
.registers()
.iter()
.map(|e| e.to_u64())
.collect::<Vec<u64>>(),
mem_checksum(machine.memory_mut())
);
let instruction_size = instruction_length(inst);
let next_pc = machine
.pc()
Expand All @@ -1575,14 +1593,15 @@ pub fn execute_with_thread<Mac: Machine>(
machine: &mut Mac,
thread: &Thread<Mac>,
) -> Result<(), Error> {
let instruction_size = instruction_length(inst);
let next_pc = machine
.pc()
.overflowing_add(&Mac::REG::from_u8(instruction_size));
machine.update_pc(next_pc);
let r = thread(machine, inst);
machine.commit_pc();
r
execute(inst, machine)
// let instruction_size = instruction_length(inst);
// let next_pc = machine
// .pc()
// .overflowing_add(&Mac::REG::from_u8(instruction_size));
// machine.update_pc(next_pc);
// let r = thread(machine, inst);
// machine.commit_pc();
// r
}

pub type Thread<Mac> = fn(&mut Mac, Instruction) -> Result<(), Error>;
Expand Down

0 comments on commit c3f6e17

Please sign in to comment.