git @ Cat's Eye Technologies SixtyPical / 6c1c1cb
Include final RTS when emitting trampolines for indirect calls. Chris Pressey 3 years ago
3 changed file(s) with 17 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
1111 * Added `define name routine {...}` syntax; `routine name {...}` is now legacy.
1212 * Removed the evaluator. The reference implementation only analyzes and compiles.
1313 * Fixed bug where index register wasn't required to be initialized before table access.
14 * Fixed bug where trampolines for indirect calls weren't including a final `RTS`.
1415
1516 0.10
1617 ----
7777 for location, label in self.trampolines.iteritems():
7878 self.emitter.resolve_label(label)
7979 self.emitter.emit(JMP(Indirect(self.labels[location.name])))
80 self.emitter.emit(RTS())
8081
8182 # initialized data
8283 for defn in program.defns:
592592 | call foo
593593 | }
594594 = $080D LDA #$1B
595 = $080F STA $0821
595 = $080F STA $0822
596596 = $0812 LDA #$08
597 = $0814 STA $0822
597 = $0814 STA $0823
598598 = $0817 JSR $081E
599599 = $081A RTS
600600 = $081B LDX #$C8
601601 = $081D RTS
602 = $081E JMP ($0821)
602 = $081E JMP ($0822)
603603 = $0821 RTS
604604
605605 goto.
655655 | }
656656 = $080D LDX #$00
657657 = $080F LDA #$35
658 = $0811 STA $083B
658 = $0811 STA $083C
659659 = $0814 LDA #$08
660 = $0816 STA $083C
661 = $0819 LDA $083B
662 = $081C STA $083D,X
663 = $081F LDA $083C
664 = $0822 STA $093D,X
665 = $0825 LDA $083D,X
666 = $0828 STA $083B
667 = $082B LDA $093D,X
668 = $082E STA $083C
660 = $0816 STA $083D
661 = $0819 LDA $083C
662 = $081C STA $083E,X
663 = $081F LDA $083D
664 = $0822 STA $093E,X
665 = $0825 LDA $083E,X
666 = $0828 STA $083C
667 = $082B LDA $093E,X
668 = $082E STA $083D
669669 = $0831 JSR $0838
670670 = $0834 RTS
671671 = $0835 LDX #$C8
672672 = $0837 RTS
673 = $0838 JMP ($083B)
673 = $0838 JMP ($083C)
674 = $083B RTS
674675
675676 ### word operations
676677