From fbb4ba4bd8524bac2445cbfc437b59dbbf5e4ef7 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 23 Dec 2017 02:41:41 +0100 Subject: [PATCH] fix jump jsr/rts --- il65/codegen.py | 5 +++-- testsource/calls.ill | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/il65/codegen.py b/il65/codegen.py index b32da320e..640e353b7 100644 --- a/il65/codegen.py +++ b/il65/codegen.py @@ -422,14 +422,15 @@ class CodeGenerator: targetstr = stmt.target.name or Parser.to_hex(stmt.address) else: raise TypeError("call sub target should be mmapped") + if stmt.is_goto: + self.p("\t\tjmp " + targetstr) + return clobbered = set() # type: Set[str] if targetdef.clobbered_registers: if stmt.preserve_regs: # @todo make this work with the separate assignment statements for the parameters.. :( clobbered = targetdef.clobbered_registers with self.preserving_registers(clobbered): self.p("\t\tjsr " + targetstr) - if stmt.is_goto: - self.p("\t\trts") return if isinstance(stmt.target, ParseResult.IndirectValue): if stmt.target.name: diff --git a/testsource/calls.ill b/testsource/calls.ill index 94af6b746..5a5a285d2 100644 --- a/testsource/calls.ill +++ b/testsource/calls.ill @@ -15,7 +15,7 @@ const .float constf = 3.4556677 const .text constt = "derp" - subx sub1 () -> () = $ffdd + subx sub1 () -> (X?) = $ffdd bar @@ -24,7 +24,7 @@ bar go [AX] go [var1] go [mem1] - go [#mem1] ; @todo error: indirection of address-of makes no sense + go [#mem1] ; @todo error: indirection of address-of makes no sense, should have outputted jmp mem1 instead of jmp(mem1) go [$c2.word] go [$c2dd.word] go $c000