diff --git a/eg/word-table.60p b/eg/word-table.60p index 2de788d..3b22900 100644 --- a/eg/word-table.60p +++ b/eg/word-table.60p @@ -9,5 +9,5 @@ routine main ld x, 0 copy 777, one copy one, many + x - copy many + x, one + //copy many + x, one } diff --git a/src/sixtypical/compiler.py b/src/sixtypical/compiler.py index 11a0cb6..01727b6 100644 --- a/src/sixtypical/compiler.py +++ b/src/sixtypical/compiler.py @@ -363,10 +363,17 @@ class Compiler(object): if src.type == TYPE_WORD and dest.ref.type == TYPE_WORD_TABLE: src_label = self.labels[src.name] dest_label = self.labels[dest.ref.name] - raise NotImplementedError("""\ -What we will need to do here, is to have TWO 'labels' per name, one for the high byte table, -and one for the low byte table. Then select AbsoluteX() or AbsoluteY() addressing on those -tables. And use that in the STA() part.""") + addressing_mode = None + if dest.index == REG_X: + addressing_mode = AbsoluteX + elif dest.index == REG_Y: + addressing_mode = AbsoluteY + else: + raise NotImplementedError(dest) + self.emitter.emit(LDA(Absolute(src_label))) + self.emitter.emit(STA(AbsoluteX(dest_label))) + self.emitter.emit(LDA(Absolute(Offset(src_label, 1)))) + self.emitter.emit(STA(AbsoluteX(Offset(dest_label, 256)))) else: raise NotImplementedError diff --git a/tests/SixtyPical Compilation.md b/tests/SixtyPical Compilation.md index 2714121..32e86d6 100644 --- a/tests/SixtyPical Compilation.md +++ b/tests/SixtyPical Compilation.md @@ -453,7 +453,7 @@ Copy routine to vector, inside an `interrupts off` block. = $081A INX = $081B RTS -Copy word to word table and back. +Copy word to word table. | word one | word table many @@ -466,15 +466,17 @@ Copy word to word table and back. | ld x, 0 | copy 777, one | copy one, many + x - | copy many + x, one | } = $080D LDX #$00 - = $08.. LDA #$D0 - = $080F STA $0818 - = $0812 LDA #$07 - = $0814 STA $0819 - = ... - = $08.. RTS + = $080F LDA #$09 + = $0811 STA $0826 + = $0814 LDA #$03 + = $0816 STA $0827 + = $0819 LDA $0826 + = $081C STA $0828,X + = $081F LDA $0827 + = $0822 STA $0928,X + = $0825 RTS Indirect call.