aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2016-07-01 19:37:38 +0200
committerCamil Staps2016-07-01 19:37:38 +0200
commitb3f1e3ff0404a5182b6eed2d88014b4b4fbd69c2 (patch)
treec2dbd5b0a43fffc6119510bdc2f5324aa3a0e3b5
parentAssembler (diff)
Moved to directory, added test program
-rw-r--r--ABC/AStack.dcl (renamed from AStack.dcl)0
-rw-r--r--ABC/AStack.icl (renamed from AStack.icl)0
-rw-r--r--ABC/Assembler.dcl (renamed from Assembler.dcl)0
-rw-r--r--ABC/Assembler.icl (renamed from Assembler.icl)0
-rw-r--r--ABC/BStack.dcl (renamed from BStack.dcl)0
-rw-r--r--ABC/BStack.icl (renamed from BStack.icl)0
-rw-r--r--ABC/CStack.dcl (renamed from CStack.dcl)0
-rw-r--r--ABC/CStack.icl (renamed from CStack.icl)0
-rw-r--r--ABC/Def.dcl (renamed from Def.dcl)0
-rw-r--r--ABC/Def.icl (renamed from Def.icl)0
-rw-r--r--ABC/Driver.dcl (renamed from Driver.dcl)0
-rw-r--r--ABC/Driver.icl (renamed from Driver.icl)0
-rw-r--r--ABC/GraphStore.dcl (renamed from GraphStore.dcl)0
-rw-r--r--ABC/GraphStore.icl (renamed from GraphStore.icl)0
-rw-r--r--ABC/IO.dcl (renamed from IO.dcl)0
-rw-r--r--ABC/IO.icl (renamed from IO.icl)0
-rw-r--r--ABC/Instructions.dcl (renamed from Instructions.dcl)0
-rw-r--r--ABC/Instructions.icl (renamed from Instructions.icl)0
-rw-r--r--ABC/Machine.dcl (renamed from Machine.dcl)0
-rw-r--r--ABC/Machine.icl (renamed from Machine.icl)0
-rw-r--r--ABC/Misc.dcl (renamed from Misc.dcl)0
-rw-r--r--ABC/Misc.icl (renamed from Misc.icl)0
-rw-r--r--ABC/Nodes.dcl (renamed from Nodes.dcl)0
-rw-r--r--ABC/Nodes.icl (renamed from Nodes.icl)0
-rw-r--r--ABC/Program.dcl (renamed from Program.dcl)0
-rw-r--r--ABC/Program.icl (renamed from Program.icl)0
-rw-r--r--test.icl148
27 files changed, 148 insertions, 0 deletions
diff --git a/AStack.dcl b/ABC/AStack.dcl
index 423b81c..423b81c 100644
--- a/AStack.dcl
+++ b/ABC/AStack.dcl
diff --git a/AStack.icl b/ABC/AStack.icl
index 0a91ecd..0a91ecd 100644
--- a/AStack.icl
+++ b/ABC/AStack.icl
diff --git a/Assembler.dcl b/ABC/Assembler.dcl
index f750609..f750609 100644
--- a/Assembler.dcl
+++ b/ABC/Assembler.dcl
diff --git a/Assembler.icl b/ABC/Assembler.icl
index 9de0708..9de0708 100644
--- a/Assembler.icl
+++ b/ABC/Assembler.icl
diff --git a/BStack.dcl b/ABC/BStack.dcl
index 95cf86e..95cf86e 100644
--- a/BStack.dcl
+++ b/ABC/BStack.dcl
diff --git a/BStack.icl b/ABC/BStack.icl
index a1caafd..a1caafd 100644
--- a/BStack.icl
+++ b/ABC/BStack.icl
diff --git a/CStack.dcl b/ABC/CStack.dcl
index 31d72de..31d72de 100644
--- a/CStack.dcl
+++ b/ABC/CStack.dcl
diff --git a/CStack.icl b/ABC/CStack.icl
index 74ca885..74ca885 100644
--- a/CStack.icl
+++ b/ABC/CStack.icl
diff --git a/Def.dcl b/ABC/Def.dcl
index db2c0c0..db2c0c0 100644
--- a/Def.dcl
+++ b/ABC/Def.dcl
diff --git a/Def.icl b/ABC/Def.icl
index 81bfeee..81bfeee 100644
--- a/Def.icl
+++ b/ABC/Def.icl
diff --git a/Driver.dcl b/ABC/Driver.dcl
index e5dd9f6..e5dd9f6 100644
--- a/Driver.dcl
+++ b/ABC/Driver.dcl
diff --git a/Driver.icl b/ABC/Driver.icl
index aa89ae1..aa89ae1 100644
--- a/Driver.icl
+++ b/ABC/Driver.icl
diff --git a/GraphStore.dcl b/ABC/GraphStore.dcl
index 108a77e..108a77e 100644
--- a/GraphStore.dcl
+++ b/ABC/GraphStore.dcl
diff --git a/GraphStore.icl b/ABC/GraphStore.icl
index 0f32994..0f32994 100644
--- a/GraphStore.icl
+++ b/ABC/GraphStore.icl
diff --git a/IO.dcl b/ABC/IO.dcl
index 501d8cc..501d8cc 100644
--- a/IO.dcl
+++ b/ABC/IO.dcl
diff --git a/IO.icl b/ABC/IO.icl
index a7cda49..a7cda49 100644
--- a/IO.icl
+++ b/ABC/IO.icl
diff --git a/Instructions.dcl b/ABC/Instructions.dcl
index 45bd568..45bd568 100644
--- a/Instructions.dcl
+++ b/ABC/Instructions.dcl
diff --git a/Instructions.icl b/ABC/Instructions.icl
index 6317972..6317972 100644
--- a/Instructions.icl
+++ b/ABC/Instructions.icl
diff --git a/Machine.dcl b/ABC/Machine.dcl
index de98de2..de98de2 100644
--- a/Machine.dcl
+++ b/ABC/Machine.dcl
diff --git a/Machine.icl b/ABC/Machine.icl
index ab1acb4..ab1acb4 100644
--- a/Machine.icl
+++ b/ABC/Machine.icl
diff --git a/Misc.dcl b/ABC/Misc.dcl
index 3e632bf..3e632bf 100644
--- a/Misc.dcl
+++ b/ABC/Misc.dcl
diff --git a/Misc.icl b/ABC/Misc.icl
index 15e5b9d..15e5b9d 100644
--- a/Misc.icl
+++ b/ABC/Misc.icl
diff --git a/Nodes.dcl b/ABC/Nodes.dcl
index 9edd604..9edd604 100644
--- a/Nodes.dcl
+++ b/ABC/Nodes.dcl
diff --git a/Nodes.icl b/ABC/Nodes.icl
index fa29cb4..fa29cb4 100644
--- a/Nodes.icl
+++ b/ABC/Nodes.icl
diff --git a/Program.dcl b/ABC/Program.dcl
index ffdf948..ffdf948 100644
--- a/Program.dcl
+++ b/ABC/Program.dcl
diff --git a/Program.icl b/ABC/Program.icl
index 4a34ec6..4a34ec6 100644
--- a/Program.icl
+++ b/ABC/Program.icl
diff --git a/test.icl b/test.icl
new file mode 100644
index 0000000..21431bf
--- /dev/null
+++ b/test.icl
@@ -0,0 +1,148 @@
+module test
+
+import StdEnv
+
+import ABC.Machine
+
+Start = toString end.io
+where
+ (prog,descs) = assemble length
+ state = boot (prog,descs)
+ end = fetch_cycle state
+
+rts :: Assembler
+rts
+ = [ Descriptor "INT" "_rnf" 0 "integer"
+ , Descriptor "BOOL" "_rnf" 0 "boolean"
+ , Jmp "init_graph"
+ , Label "init_graph"
+ , Create
+ , Fill "Start" 0 "n_Start" 0
+ , Jsr "_driver"
+ , Print "\n"
+ , Halt
+ , Label "_driver"
+ , PushI 0
+ , Label "_print"
+ , JsrEval
+ , GetNodeArity 0
+ , EqI_b 0 0
+ , JmpFalse "_args"
+ , Label "_print_last"
+ , PrintSymbol 0
+ , Pop_a 1
+ , Pop_b 1
+ , Label "_brackets"
+ , EqI_b 0 0
+ , JmpTrue "_exit"
+ , Print ")"
+ , DecI
+ , Jmp "_brackets"
+ , Label "_exit"
+ , Rtn
+ , Label "_args"
+ , Print "("
+ , PrintSymbol 0
+ , GetDescArity 0
+ , ReplArgs_b
+ , Pop_b 1
+ , Label "_arg_loop"
+ , Print " "
+ , EqI_b 1 0
+ , JmpFalse "_next_arg"
+ , Pop_b 1
+ , IncI
+ , Jmp "_print"
+ , Label "_next_arg"
+ , Jsr "_driver"
+ , DecI
+ , Jmp "_arg_loop"
+ , Label "_rnf"
+ , Rtn
+ , Label "_cycle"
+ , Print "cycle in spine\n"
+ , Halt
+ , Label "_type_error"
+ , Print "type error\n"
+ , Halt
+ ]
+
+ints :: Assembler
+ints
+ = [ Label "+I1"
+ , IncI
+ , Rtn
+ ]
+
+list :: Assembler
+list
+ = [ Descriptor "Cons" "_rnf" 2 "Cons"
+ , Descriptor "Nil" "_rnf" 0 "Nil"
+ ]
+
+length :: Assembler // p. 87-88
+length
+ = rts ++
+ list ++
+ ints ++
+ [ Descriptor "Length" "a_Length" 2 "Length"
+
+ , Label "n_Length"
+ , SetEntry "_cycle" 0
+ , PushArgs 0 2 2
+
+ , Label "a_Length"
+ , Push_a 1
+ , JsrEval
+ , Pop_a 1
+
+ , Label "Length1"
+ , EqDescArity "Cons" 2 1
+ , JmpFalse "Length2"
+ , PushArgs 1 2 2
+ , Push_a 1
+ , JsrEval
+ , Create
+ , Create
+ , FillI 1 0
+ , Push_a 5
+ , Jsr "+I1"
+ , Update_a 1 5
+ , Update_a 0 4
+ , Pop_a 4
+ , Jmp "Length1"
+
+ , Label "Length2"
+ , EqDescArity "Nil" 0 1
+ , JmpFalse "Length3"
+ , Fill_a 0 2
+ , Pop_a 2
+ , Rtn
+
+ , Label "Length3"
+ , Jmp "_type_error"
+
+ , Descriptor "Start" "n_Start" 0 "Start"
+ , Label "n_Start"
+ , Create
+ , Create
+ , Create
+ , Fill "Nil" 0 "_rnf" 0
+ , Create
+ , FillI 1 0
+ , Fill "Cons" 2 "_rnf" 2
+ , Fill "Length" 1 "n_Length" 1
+ //, Jmp "_driver"
+ , Dump ""
+ , Halt
+ ]
+
+cons_1_nil :: Assembler // p. 45, doesn't work (Nil/Cons no descriptors)
+cons_1_nil
+ = [ Create
+ , Create
+ , Fill "Nil" 0 "_rnf" 0
+ , Create
+ , FillI 1 0
+ , Fill "Cons" 2 "_rnf" 2
+ ]