aboutsummaryrefslogtreecommitdiff
path: root/urm.ml
diff options
context:
space:
mode:
authorpacien2018-04-27 11:59:42 +0200
committerpacien2018-04-27 11:59:42 +0200
commit3e0c5de7c0434678218a6583887f7b849dc684f9 (patch)
treebf830d9e3c9d87c7bc9e87e3e6c3b320dfa6fff5 /urm.ml
parent880457ca0c585b06ba5ed9f431796b048722cc06 (diff)
downloadurm-3e0c5de7c0434678218a6583887f7b849dc684f9.tar.gz
Implement trace mode
Diffstat (limited to 'urm.ml')
-rw-r--r--urm.ml14
1 files changed, 10 insertions, 4 deletions
diff --git a/urm.ml b/urm.ml
index be9f7e4..3b7068b 100644
--- a/urm.ml
+++ b/urm.ml
@@ -23,12 +23,18 @@ let urm_apply urm =
23 | _, _ -> { instptr = urm.instptr ; regs = urm.regs } |> urm_move_down 23 | _, _ -> { instptr = urm.instptr ; regs = urm.regs } |> urm_move_down
24 in if instptr_end urm.instptr then urm else aux (instptr_get urm.instptr) 24 in if instptr_end urm.instptr then urm else aux (instptr_get urm.instptr)
25 25
26(* Launches the URM *) 26let rec urm_run_pre pre = function
27let rec urm_run = function
28 | { instptr = InstPtr(_, []) ; regs = reg_list } -> reg_list 27 | { instptr = InstPtr(_, []) ; regs = reg_list } -> reg_list
29 | urm -> urm_apply urm |> urm_run 28 | urm -> pre urm; urm_apply urm |> urm_run_pre pre
30 29
31let urm_run_trace = urm_run (* TODO *) 30let urm_run = urm_run_pre (fun _ -> ())
31
32let urm_run_trace =
33 let print_func u =
34 print_endline (instptr_string u.instptr);
35 print_endline (regs_string u.regs);
36 print_newline ()
37 in urm_run_pre (print_func)
32 38
33(* Creates an URM from a command list and a register list *) 39(* Creates an URM from a command list and a register list *)
34let urm_mk cmd_list reg_list = { instptr = (instptr_mk cmd_list) ; regs = reg_list } 40let urm_mk cmd_list reg_list = { instptr = (instptr_mk cmd_list) ; regs = reg_list }