Last change
on this file since 573 was
451,
checked in by mulligan, 10 years ago
|
Removed more debugging stuff from Test.ml.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[147] | 1 | open BitVectors;; |
---|
[195] | 2 | open ASMInterpret;; |
---|
[147] | 3 | open Util;; |
---|
[444] | 4 | open IntelHex;; |
---|
[147] | 5 | open Pretty;; |
---|
| 6 | |
---|
[429] | 7 | let hex = IntelHex.intel_hex_of_file Sys.argv.(1) in |
---|
[138] | 8 | let mem = IntelHex.process_intel_hex hex in |
---|
| 9 | let status = ASMInterpret.load_mem mem ASMInterpret.initialize in |
---|
[450] | 10 | (* Nicolas, see here for example of exporting HEX: *) |
---|
[448] | 11 | let _ = file_of_intel_hex "hex_test_out.hex" (pack_exported_code_memory 12 114 status.code_memory) in |
---|
[138] | 12 | let observe status = |
---|
| 13 | let pc = status.ASMInterpret.pc in |
---|
| 14 | let instr,_,_ = ASMInterpret.fetch status.ASMInterpret.code_memory pc in |
---|
[195] | 15 | let _ = prerr_string (BitVectors.hex_string_of_vect pc) in |
---|
| 16 | let _ = prerr_endline (": " ^ pp_instruction instr) in |
---|
[451] | 17 | prerr_endline <*> string_of_status $ status |
---|
[138] | 18 | in |
---|
[147] | 19 | (* DPM: for debugging! *) |
---|
| 20 | let mem_pretty_print status = |
---|
| 21 | let rec aux status pc = |
---|
| 22 | let instr, pc', cost = ASMInterpret.fetch status.ASMInterpret.code_memory pc in |
---|
| 23 | prerr_string $ ((hex_string_of_vect pc) ^ ": "); |
---|
| 24 | prerr_string $ (pp_instruction instr) ^ " "; |
---|
| 25 | prerr_endline $ string_of_int cost; |
---|
[150] | 26 | if int_of_vect pc' > 200 then (* DPM: hardcoded on a case-by-case basis *) |
---|
[147] | 27 | () |
---|
| 28 | else |
---|
| 29 | aux status pc' |
---|
| 30 | in |
---|
| 31 | aux status status.ASMInterpret.pc; |
---|
| 32 | prerr_endline "-------------------------------------" |
---|
| 33 | in |
---|
[150] | 34 | mem_pretty_print status; |
---|
[138] | 35 | ASMInterpret.execute observe status |
---|
| 36 | ;; |
---|
Note: See
TracBrowser
for help on using the repository browser.