source: Deliverables/D4.1/test.ml @ 150

Last change on this file since 150 was 150, checked in by mulligan, 9 years ago

Manages to load and emulate a simple array program. A few obscure bugs.

File size: 1.0 KB
Line 
1open BitVectors;;
2open Util;;
3open Pretty;;
4
5let hex = IntelHex.intel_hex_of_file "Test.hex" in
6let mem = IntelHex.process_intel_hex hex in
7let status = ASMInterpret.load_mem mem ASMInterpret.initialize in
8let observe status =
9 let pc = status.ASMInterpret.pc in
10 let instr,_,_ = ASMInterpret.fetch status.ASMInterpret.code_memory pc in
11   prerr_string (BitVectors.hex_string_of_vect pc) ;
12   prerr_endline (": " ^ pp_instruction instr)
13in
14(* DPM: for debugging! *)
15let mem_pretty_print status =
16  let rec aux status pc =
17    let instr, pc', cost = ASMInterpret.fetch status.ASMInterpret.code_memory pc in
18      prerr_string $ ((hex_string_of_vect pc) ^ ": ");
19      prerr_string $ (pp_instruction instr) ^ " ";
20      prerr_endline $ string_of_int cost;
21      if int_of_vect pc' > 200 then (* DPM: hardcoded on a case-by-case basis *)
22        ()
23      else
24        aux status pc'
25  in
26    aux status status.ASMInterpret.pc;
27    prerr_endline "-------------------------------------"
28in
29 mem_pretty_print status;
30 ASMInterpret.execute observe status
31;;
Note: See TracBrowser for help on using the repository browser.