1 | 1 |
|
2 | 2 |
from sixtypical.ast import Program, Routine, Block, Instr
|
3 | 3 |
from sixtypical.model import (
|
4 | |
ConstantRef, LocationRef, IndirectRef, AddressRef,
|
5 | |
TYPE_BIT, TYPE_BYTE, TYPE_WORD, BufferType, PointerType, RoutineType, VectorType,
|
|
4 |
ConstantRef, LocationRef, IndexedRef, IndirectRef, AddressRef,
|
|
5 |
TYPE_BIT, TYPE_BYTE, TYPE_WORD, TYPE_WORD_TABLE, BufferType, PointerType, RoutineType, VectorType,
|
6 | 6 |
REG_A, REG_X, REG_Y, FLAG_C
|
7 | 7 |
)
|
8 | 8 |
from sixtypical.emitter import Byte, Label, Offset, LowAddressByte, HighAddressByte
|
|
168 | 168 |
raise UnsupportedOpcodeError(instr)
|
169 | 169 |
elif isinstance(dest, LocationRef) and src.type == TYPE_WORD and isinstance(dest.type, PointerType):
|
170 | 170 |
if isinstance(src, ConstantRef):
|
171 | |
dest_label = self.labels[dest.name] # this. is. zero-page.
|
|
171 |
dest_label = self.labels[dest.name]
|
172 | 172 |
self.emitter.emit(LDA(ZeroPage(dest_label)))
|
173 | 173 |
self.emitter.emit(ADC(Immediate(Byte(src.low_byte()))))
|
174 | 174 |
self.emitter.emit(STA(ZeroPage(dest_label)))
|
|
177 | 177 |
self.emitter.emit(STA(ZeroPage(Offset(dest_label, 1))))
|
178 | 178 |
elif isinstance(src, LocationRef):
|
179 | 179 |
src_label = self.labels[src.name]
|
180 | |
dest_label = self.labels[dest.name] # this. is. zero-page.
|
|
180 |
dest_label = self.labels[dest.name]
|
181 | 181 |
self.emitter.emit(LDA(ZeroPage(dest_label)))
|
182 | 182 |
self.emitter.emit(ADC(Absolute(src_label)))
|
183 | 183 |
self.emitter.emit(STA(ZeroPage(dest_label)))
|
|
344 | 344 |
self.emitter.emit(STA(ZeroPage(dest_label)))
|
345 | 345 |
self.emitter.emit(LDA(Immediate(LowAddressByte(src_label))))
|
346 | 346 |
self.emitter.emit(STA(ZeroPage(Offset(dest_label, 1))))
|
|
347 |
elif isinstance(src, LocationRef) and isinstance(dest, IndexedRef):
|
|
348 |
if src.type == TYPE_WORD and dest.ref.type == TYPE_WORD_TABLE:
|
|
349 |
src_label = self.labels[src.name]
|
|
350 |
dest_label = self.labels[dest.ref.name]
|
|
351 |
raise NotImplementedError("""\
|
|
352 |
What we will need to do here, is to have TWO 'labels' per name, one for the high byte table,
|
|
353 |
and one for the low byte table. Then select AbsoluteX() or AbsoluteY() addressing on those
|
|
354 |
tables. And use that in the STA() part.""")
|
|
355 |
else:
|
|
356 |
raise NotImplementedError
|
|
357 |
|
347 | 358 |
elif not isinstance(src, (ConstantRef, LocationRef)) or not isinstance(dest, LocationRef):
|
348 | 359 |
raise NotImplementedError((src, dest))
|
349 | 360 |
elif src.type == TYPE_BYTE and dest.type == TYPE_BYTE:
|