diff options
Diffstat (limited to 'src/urm.ml')
-rw-r--r-- | src/urm.ml | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -15,11 +15,11 @@ let urm_move_down urm = { instptr = instptr_move_down urm.instptr ; regs = urm.r | |||
15 | (* Applies the current instruction pointed by the pointer of instruction. Modifies the pointer of instruction for every instruction *) | 15 | (* Applies the current instruction pointed by the pointer of instruction. Modifies the pointer of instruction for every instruction *) |
16 | let urm_apply urm = | 16 | let urm_apply urm = |
17 | let aux = function | 17 | let aux = function |
18 | | _, Zero(a) -> { instptr = urm.instptr ; regs = regs_set (urm.regs) a 0 } |> urm_move_down | 18 | | _, URMZero(a) -> { instptr = urm.instptr ; regs = regs_set (urm.regs) a 0 } |> urm_move_down |
19 | | _, Copy(a, b) when a != b -> { instptr = urm.instptr ; regs = regs_set urm.regs a (regs_get urm.regs b) } |> urm_move_down | 19 | | _, URMCopy(a, b) when a != b -> { instptr = urm.instptr ; regs = regs_set urm.regs a (regs_get urm.regs b) } |> urm_move_down |
20 | | _, Copy(a, b) -> failwith "Copy from one register to itself" | 20 | | _, URMCopy(a, b) -> failwith "Copy from one register to itself" |
21 | | _, Succ(a) -> { instptr = urm.instptr ; regs = regs_set urm.regs a ((regs_get urm.regs a) + 1) } |> urm_move_down | 21 | | _, URMSucc(a) -> { instptr = urm.instptr ; regs = regs_set urm.regs a ((regs_get urm.regs a) + 1) } |> urm_move_down |
22 | | _, Jump(a, b, c) when (regs_get urm.regs a) = (regs_get urm.regs b) -> { instptr = (instptr_jump urm.instptr (fst (instptr_get urm.instptr) - c)) ; regs = urm.regs } | 22 | | _, URMJump(a, b, c) when (regs_get urm.regs a) = (regs_get urm.regs b) -> { instptr = (instptr_jump urm.instptr (fst (instptr_get urm.instptr) - c)) ; regs = urm.regs } |
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 | ||
@@ -38,4 +38,3 @@ let urm_run_trace = | |||
38 | 38 | ||
39 | (* Creates an URM from a command list and a register list *) | 39 | (* Creates an URM from a command list and a register list *) |
40 | let urm_mk cmd_list reg_list = { instptr = (instptr_mk cmd_list) ; regs = reg_list } | 40 | let urm_mk cmd_list reg_list = { instptr = (instptr_mk cmd_list) ; regs = reg_list } |
41 | |||