fix jump jsr/rts

This commit is contained in:
Irmen de Jong 2017-12-23 02:41:41 +01:00
parent fdf9054b99
commit fbb4ba4bd8
2 changed files with 5 additions and 4 deletions

View File

@ -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:

View File

@ -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