fixed ass2
This commit is contained in:
parent
c707e3253c
commit
1bbc80de29
37 changed files with 753 additions and 18 deletions
|
|
@ -98,6 +98,27 @@ let print_memory (state : state) (n : int) : unit =
|
|||
done;
|
||||
Printf.printf "\n"
|
||||
|
||||
let print_memory_pretty (state : state) (n : int) : unit =
|
||||
let mem = state.memory in
|
||||
let len = Bytes.length mem in
|
||||
let limit = min n len in
|
||||
Printf.printf "Memory dump (first %d bytes):\n" limit;
|
||||
|
||||
for i = 0 to limit - 1 do
|
||||
(* Print address at the start of each row *)
|
||||
if i mod 16 = 0 then
|
||||
Printf.printf "%04X: " i;
|
||||
|
||||
let byte = Char.code (Bytes.get mem i) in
|
||||
Printf.printf "%02X " byte;
|
||||
|
||||
(* Newline after 16 bytes *)
|
||||
if (i + 1) mod 16 = 0 then Printf.printf "\n";
|
||||
done;
|
||||
|
||||
(* Final newline if last line was incomplete *)
|
||||
if limit mod 16 <> 0 then Printf.printf "\n"
|
||||
|
||||
let print_regs state : unit =
|
||||
let regs = state.regs in
|
||||
Printf.printf "A: %06X\n" regs.a;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue