aboutsummaryrefslogtreecommitdiff
path: root/reg.ml
diff options
context:
space:
mode:
authorpacien2018-04-22 22:39:56 +0200
committerpacien2018-04-22 22:39:56 +0200
commit0027c7b647e1b345badbb01bcafd22feee075470 (patch)
tree8cf72c45c517b20c1adfe4eba25f8b3358115282 /reg.ml
parentdb9de5bc717be46f0ca2dc1aa975c75adca6264d (diff)
downloadurm-0027c7b647e1b345badbb01bcafd22feee075470.tar.gz
Implement program execution from command line
Diffstat (limited to 'reg.ml')
-rw-r--r--reg.ml3
1 files changed, 3 insertions, 0 deletions
diff --git a/reg.ml b/reg.ml
index c452282..45bbb4b 100644
--- a/reg.ml
+++ b/reg.ml
@@ -8,6 +8,7 @@ open Common
8let reg_idx (Reg(idx, _)) = idx 8let reg_idx (Reg(idx, _)) = idx
9let reg_val (Reg(_, value)) = value 9let reg_val (Reg(_, value)) = value
10let reg_compar l r = (reg_val l) - (reg_val r) 10let reg_compar l r = (reg_val l) - (reg_val r)
11let reg_string (Reg (index, value)) = (string_of_int index) ^ ": " ^ (string_of_int value)
11 12
12let regs_get reglist index = 13let regs_get reglist index =
13 List.find (fun (Reg(idx, _)) -> idx = index) reglist |> reg_val 14 List.find (fun (Reg(idx, _)) -> idx = index) reglist |> reg_val
@@ -15,3 +16,5 @@ let regs_get reglist index =
15let regs_set reglist index value = 16let regs_set reglist index value =
16 Reg(index, value) :: List.filter (fun (Reg(idx, _)) -> idx != index) reglist 17 Reg(index, value) :: List.filter (fun (Reg(idx, _)) -> idx != index) reglist
17 18
19let rec regs_string reglist = List.map (reg_string) reglist |> String.concat ", "
20