From 2ee0ef30cb01415cdb9cdbf4adc5ad279f44f661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Tue, 7 Jul 2009 10:33:02 +0200 Subject: push command line params onto stack --- src/back/generator.py | 13 ++++++------- src/back/tac.py | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/back') 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): -- cgit v1.2.3