summaryrefslogtreecommitdiffstats
path: root/src/back/generator.py
diff options
context:
space:
mode:
authorBenedikt Böhm <bb@xnull.de>2009-07-06 21:21:19 +0200
committerBenedikt Böhm <bb@xnull.de>2009-07-06 21:21:19 +0200
commitac4fb25412982447af2e718d3824e6acf7d3a2dd (patch)
tree4eb8d49be8363dda95e3e1851e8dc04e6c3cb4f5 /src/back/generator.py
parent37aec7789434c3ade9a1df630b1eec6c997487b2 (diff)
downloadswppy-ac4fb25412982447af2e718d3824e6acf7d3a2dd.tar.gz
swppy-ac4fb25412982447af2e718d3824e6acf7d3a2dd.tar.xz
swppy-ac4fb25412982447af2e718d3824e6acf7d3a2dd.zip
implement print statement
Diffstat (limited to '')
-rw-r--r--src/back/generator.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/back/generator.py b/src/back/generator.py
index 414cf7b..7ca2658 100644
--- a/src/back/generator.py
+++ b/src/back/generator.py
@@ -90,6 +90,14 @@ class Generator(object):
elif tac.op == Op.RETURN:
self.emit("ADD rv, r0, r%d" % tac.arg1)
self.emit(tac)
+ elif tac.op == Op.PRINT:
+ r = Register().new()
+ self.emit("PUSH r%d" % tac.arg1)
+ self.emit("MOV r%d, %d" % (r, 1))
+ self.emit("PUSH r%d" % r)
+ self.emit("SYS")
+ self.emit("POP r0")
+ self.emit("POP r0")
elif isinstance(tac, FunctionPrologue):
self.generate_prologue(tac.name)
elif isinstance(tac, FunctionEpilogue):