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

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

Added printout of processor status when we enter the infinite SJMP loop
at the end. Need to add printout of register status, though. Every
other important SFR, etc. is already implemented.

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