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) targetstr = stmt.target.name or Parser.to_hex(stmt.address)
else: else:
raise TypeError("call sub target should be mmapped") raise TypeError("call sub target should be mmapped")
if stmt.is_goto:
self.p("\t\tjmp " + targetstr)
return
clobbered = set() # type: Set[str] clobbered = set() # type: Set[str]
if targetdef.clobbered_registers: if targetdef.clobbered_registers:
if stmt.preserve_regs: # @todo make this work with the separate assignment statements for the parameters.. :( if stmt.preserve_regs: # @todo make this work with the separate assignment statements for the parameters.. :(
clobbered = targetdef.clobbered_registers clobbered = targetdef.clobbered_registers
with self.preserving_registers(clobbered): with self.preserving_registers(clobbered):
self.p("\t\tjsr " + targetstr) self.p("\t\tjsr " + targetstr)
if stmt.is_goto:
self.p("\t\trts")
return return
if isinstance(stmt.target, ParseResult.IndirectValue): if isinstance(stmt.target, ParseResult.IndirectValue):
if stmt.target.name: if stmt.target.name:

View File

@ -15,7 +15,7 @@
const .float constf = 3.4556677 const .float constf = 3.4556677
const .text constt = "derp" const .text constt = "derp"
subx sub1 () -> () = $ffdd subx sub1 () -> (X?) = $ffdd
bar bar
@ -24,7 +24,7 @@ bar
go [AX] go [AX]
go [var1] go [var1]
go [mem1] 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 [$c2.word]
go [$c2dd.word] go [$c2dd.word]
go $c000 go $c000