summaryrefslogtreecommitdiffstats
path: root/src/back
diff options
context:
space:
mode:
authorBenedikt Böhm <bb@xnull.de>2009-07-07 10:33:02 +0200
committerBenedikt Böhm <bb@xnull.de>2009-07-07 10:33:02 +0200
commit2ee0ef30cb01415cdb9cdbf4adc5ad279f44f661 (patch)
tree61e30710951f7ee3fd8ebbc5e059a0e6fb92316c /src/back
parentd15276557c65de2a1941632ec9024dea261cce26 (diff)
downloadswppy-2ee0ef30cb01415cdb9cdbf4adc5ad279f44f661.tar.gz
swppy-2ee0ef30cb01415cdb9cdbf4adc5ad279f44f661.tar.xz
swppy-2ee0ef30cb01415cdb9cdbf4adc5ad279f44f661.zip
push command line params onto stack
Diffstat (limited to 'src/back')
-rw-r--r--src/back/generator.py13
-rw-r--r--src/back/tac.py1
2 files changed, 7 insertions, 7 deletions
diff --git a/src/back/generator.py b/src/back/generator.py
index 7ca2658..1ae403f 100644
--- a/src/back/generator.py
+++ b/src/back/generator.py
@@ -52,12 +52,7 @@ class Generator(object):
Register().get_registers(name).reverse()
self.emit("ADD sp, r0, bp")
self.emit("POP bp")
- if name == "main":
- self.emit("PUSH rv")
- self.emit("PUSH r0")
- self.emit("SYS")
- else:
- self.emit("RET")
+ self.emit("RET")
def generate(self):
# pass 1 - generate non-label ops
@@ -98,6 +93,10 @@ class Generator(object):
self.emit("SYS")
self.emit("POP r0")
self.emit("POP r0")
+ elif tac.op == Op.SYS:
+ self.emit("SYS")
+ else:
+ raise Exception("%s is not a valid TAC operator" % tac.op)
elif isinstance(tac, FunctionPrologue):
self.generate_prologue(tac.name)
elif isinstance(tac, FunctionEpilogue):
@@ -105,7 +104,7 @@ class Generator(object):
elif isinstance(tac, Label):
self.emit(Label(tac.name))
else:
- raise Exception("%s is not a valid TACList element", repr(tac))
+ raise Exception("%s is not a valid TACList element" % repr(tac))
# pass 2 - generate label ops
for op in self.__op_list:
diff --git a/src/back/tac.py b/src/back/tac.py
index 86ccd90..7207758 100644
--- a/src/back/tac.py
+++ b/src/back/tac.py
@@ -40,6 +40,7 @@ Op.JMP = Op("JMP") # goto x
Op.CALL = Op("CALL") # call x return in y
Op.RETURN = Op("RETURN") # return x
+Op.SYS = Op("SYS") # system call
Op.PRINT = Op("PRINT") # print x
class TAC(object):