aboutsummaryrefslogtreecommitdiff
path: root/ABC/Code
diff options
context:
space:
mode:
authorCamil Staps2016-07-03 14:42:27 +0200
committerCamil Staps2016-07-03 14:42:27 +0200
commit6025a6637dae924ec87e10d94b0b49ea81592eea (patch)
tree6e18a288cedd5adaa84ceb7737900440166202da /ABC/Code
parentMoved to directory, added test program (diff)
Added ABC.Code
Diffstat (limited to 'ABC/Code')
-rw-r--r--ABC/Code/RTS.dcl5
-rw-r--r--ABC/Code/RTS.icl60
2 files changed, 65 insertions, 0 deletions
diff --git a/ABC/Code/RTS.dcl b/ABC/Code/RTS.dcl
new file mode 100644
index 0000000..03e1759
--- /dev/null
+++ b/ABC/Code/RTS.dcl
@@ -0,0 +1,5 @@
+definition module ABC.Code.RTS
+
+from ABC.Assembler import ::Statement, ::Assembler
+
+rts :: Assembler
diff --git a/ABC/Code/RTS.icl b/ABC/Code/RTS.icl
new file mode 100644
index 0000000..f28f4d8
--- /dev/null
+++ b/ABC/Code/RTS.icl
@@ -0,0 +1,60 @@
+implementation module ABC.Code.RTS
+
+import ABC.Machine
+
+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
+ ]