git @ Cat's Eye Technologies SixtyPical / 19a196f
Compile copy[]+y. Chris Pressey 4 years ago
4 changed file(s) with 29 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
77 {
88 ld y, 0
99 copy buf, ptr
10 // copy 123, [ptr] + y
10 copy 123, [ptr] + y
1111 }
321321 self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
322322 else:
323323 raise NotImplementedError(src.type)
324 elif opcode == 'copy[]+y':
325 if src.type == TYPE_BYTE and isinstance(dest.type, PointerType):
326 if isinstance(src, ConstantRef):
327 dest_label = self.labels[dest.name]
328 self.emitter.emit(LDA(Immediate(Byte(src.value))))
329 self.emitter.emit(STA(IndirectY(dest_label)))
330 else:
331 raise NotImplementedError((src.type, dest.type))
332 else:
333 raise NotImplementedError((src.type, dest.type))
324334 else:
325335 raise NotImplementedError(opcode)
8181 return self.value.serialize()
8282
8383
84 class IndirectY(AddressingMode):
85 def __init__(self, value):
86 assert isinstance(value, Label)
87 self.value = value
88
89 def size(self):
90 return 1
91
92 def serialize(self, addr=None):
93 return self.value.serialize()
84 class IndirectY(ZeroPage):
85 pass
9486
9587
9688 class Relative(AddressingMode):
353353 | {
354354 | ld y, 0
355355 | copy buf, ptr
356 | // copy 123, [ptr] + y
357356 | }
358357 = 00c0a000a90b85fea9c085ff60
358
359 Writing through a pointer.
360
361 | buffer[2048] buf
362 | pointer ptr @ 254
363 |
364 | routine main
365 | inputs buf
366 | outputs buf, y
367 | trashes a, z, n, ptr
368 | {
369 | ld y, 0
370 | copy buf, ptr
371 | copy 123, [ptr] + y
372 | }
373 = 00c0a000a90f85fea9c085ffa97b91fe60