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

Last change on this file since 147 was 147, checked in by mulligan, 10 years ago

Changes made today: we now have an emulator that is able to emulate two
small C programs.

File size: 1.0 KB
RevLine 
[147]1open BitVectors;;
2open Util;;
3open Pretty;;
4
[145]5let hex = IntelHex.intel_hex_of_file "Test.hex" in
[138]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
[145]11   prerr_string (BitVectors.hex_string_of_vect pc) ;
[147]12   prerr_endline (": " ^ pp_instruction instr)
[138]13in
[147]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' > 105 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; *)
[138]30 ASMInterpret.execute observe status
31;;
Note: See TracBrowser for help on using the repository browser.