git @ Cat's Eye Technologies SixtyPical / 50390b0
Can `copy` a literal word to a word table. Chris Pressey 3 years ago
5 changed file(s) with 54 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
77 * The `forward` modifier can also be used to indicate that the symbol being copied
88 in a `copy` to a vector is a routine that is defined further down in the source.
99 * Initialized `word` memory locations.
10 * Can `copy` a literal word to a word table.
1011 * Fixed bug which was preventing `if` branches to diverge in what they initialized,
1112 if it was already initialized when going into the `if`.
1213 * Fixed a bug which was making it crash when trying to analyze `repeat forever` loops.
351351 else:
352352 raise TypeMismatchError((src, dest))
353353
354 elif isinstance(src, LocationRef) and isinstance(dest, IndexedRef):
354 elif isinstance(src, (LocationRef, ConstantRef)) and isinstance(dest, IndexedRef):
355355 if src.type == TYPE_WORD and dest.ref.type == TYPE_WORD_TABLE:
356356 pass
357357 else:
390390 context.assert_meaningful(src, dest.ref, dest.index)
391391 context.set_touched(src) # TODO and dest.index?
392392 context.set_written(dest.ref)
393 elif isinstance(src, ConstantRef) and isinstance(dest, IndexedRef):
394 context.assert_meaningful(src, dest.ref, dest.index)
395 context.set_written(dest.ref)
393396 elif isinstance(src, IndexedRef) and isinstance(dest, LocationRef):
394397 context.assert_meaningful(src.ref, src.index, dest)
395398 context.set_touched(dest) # TODO and src.index?
382382 self.emitter.emit(STA(addressing_mode(Offset(dest_label, 256))))
383383 else:
384384 raise NotImplementedError
385 elif isinstance(src, ConstantRef) and isinstance(dest, IndexedRef):
386 if src.type == TYPE_WORD and dest.ref.type == TYPE_WORD_TABLE:
387 dest_label = self.labels[dest.ref.name]
388 addressing_mode = None
389 if dest.index == REG_X:
390 addressing_mode = AbsoluteX
391 elif dest.index == REG_Y:
392 addressing_mode = AbsoluteY
393 else:
394 raise NotImplementedError(dest)
395 self.emitter.emit(LDA(Immediate(Byte(src.low_byte()))))
396 self.emitter.emit(STA(addressing_mode(dest_label)))
397 self.emitter.emit(LDA(Immediate(Byte(src.high_byte()))))
398 self.emitter.emit(STA(addressing_mode(Offset(dest_label, 256))))
399 else:
400 raise NotImplementedError
385401 elif isinstance(src, IndexedRef) and isinstance(dest, LocationRef):
386402 if src.ref.type == TYPE_WORD_TABLE and dest.type == TYPE_WORD:
387403 src_label = self.labels[src.ref.name]
386386 | copy one + x, many
387387 | }
388388 ? TypeMismatchError
389
390 You can also copy a literal word to a word table.
391
392 | word table many
393 |
394 | routine main
395 | inputs many
396 | outputs many
397 | trashes a, x, n, z
398 | {
399 | ld x, 0
400 | copy 9999, many + x
401 | }
402 = ok
389403
390404 ### add ###
391405
433433 = $0814 STA $0819
434434 = $0817 RTS
435435
436 You can also copy a literal word to a word table.
437
438 | word table many
439 |
440 | routine main
441 | inputs many
442 | outputs many
443 | trashes a, x, n, z
444 | {
445 | ld x, 0
446 | copy 9999, many + x
447 | }
448 = $080D LDX #$00
449 = $080F LDA #$0F
450 = $0811 STA $081A,X
451 = $0814 LDA #$27
452 = $0816 STA $091A,X
453 = $0819 RTS
454
436455 Copy vector to vector.
437456
438457 | vector bar