aboutsummaryrefslogtreecommitdiff
path: root/ABC/Program.icl
diff options
context:
space:
mode:
authorCamil Staps2016-07-01 19:37:38 +0200
committerCamil Staps2016-07-01 19:37:38 +0200
commitb3f1e3ff0404a5182b6eed2d88014b4b4fbd69c2 (patch)
treec2dbd5b0a43fffc6119510bdc2f5324aa3a0e3b5 /ABC/Program.icl
parentAssembler (diff)
Moved to directory, added test program
Diffstat (limited to 'ABC/Program.icl')
-rw-r--r--ABC/Program.icl30
1 files changed, 30 insertions, 0 deletions
diff --git a/ABC/Program.icl b/ABC/Program.icl
new file mode 100644
index 0000000..4a34ec6
--- /dev/null
+++ b/ABC/Program.icl
@@ -0,0 +1,30 @@
+implementation module ABC.Program
+
+import StdEnv
+
+import ABC.Machine
+import ABC.Misc
+
+pc_init :: InstrId
+pc_init = 0
+
+pc_next :: InstrId -> InstrId
+pc_next i = i + 1
+
+pc_halt :: InstrId -> InstrId
+pc_halt _ = -1
+
+pc_end :: InstrId -> Bool
+pc_end i = i < 0
+
+:: Location = I Instruction
+:: ProgramStore :== [Location]
+
+ps_get :: InstrId ProgramStore -> Instruction
+ps_get 0 [I p:_] = p
+ps_get _ [] = abortn "ps_get: index too large"
+ps_get i [_:ps] = ps_get (i-1) ps
+
+ps_init :: [Instruction] -> ProgramStore
+ps_init [] = []
+ps_init [i:is] = [I i:ps_init is]