git @ Cat's Eye Technologies SixtyPical / 7c8f113
Properly store address (not contents) of routine into vector table. Chris Pressey 3 years ago
4 changed file(s) with 91 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
3030 trashes print, a, x, z, n, c
3131 {
3232 ld x, 0
33 copy printa, vectors + x
33 copy printa, print
34 copy print, vectors + x
3435 inc x
35 copy printa, vectors + x
36 copy printa, print
37 copy print, vectors + x
3638 inc x
37 copy printb, vectors + x
39 copy printb, print
40 copy print, vectors + x
3841 inc x
39 copy printa, vectors + x
42 copy printa, print
43 copy print, vectors + x
4044 inc x
41 copy printb, vectors + x
45 copy printb, print
46 copy print, vectors + x
4247
4348 copy printa, print
4449
0 vector routine
1 trashes a, z, n
2 print
3
4 vector (routine
5 trashes a, z, n)
6 table[32] vectors
7
8 routine chrout
9 inputs a
10 trashes a
11 @ 65490
12
13 routine printa
14 trashes a, z, n
15 {
16 ld a, 65
17 call chrout
18 }
19
20 routine printb
21 trashes a, z, n
22 {
23 ld a, 66
24 call chrout
25 }
26
27 routine main
28 inputs vectors
29 outputs vectors
30 trashes print, a, x, z, n, c
31 {
32 ld x, 0
33 copy printa, vectors + x
34 inc x
35 copy printa, vectors + x
36 inc x
37 copy printb, vectors + x
38 inc x
39 copy printa, vectors + x
40 inc x
41 copy printb, vectors + x
42
43 ld x, 0
44 repeat {
45 copy vectors + x, print
46 call print
47 inc x
48 cmp x, 5
49 } until z
50 }
410410 self.emitter.emit(STA(self.addressing_mode_for_index(dest.index)(dest_label)))
411411 self.emitter.emit(LDA(Absolute(Offset(src_label, 1))))
412412 self.emitter.emit(STA(self.addressing_mode_for_index(dest.index)(Offset(dest_label, 256))))
413 elif isinstance(src.type, (VectorType, RoutineType)) and isinstance(dest.ref.type, TableType) and isinstance(dest.ref.type.of_type, VectorType):
413 elif isinstance(src.type, VectorType) and isinstance(dest.ref.type, TableType) and isinstance(dest.ref.type.of_type, VectorType):
414414 # FIXME this is the exact same as above - can this be simplified?
415415 src_label = self.labels[src.name]
416416 dest_label = self.labels[dest.ref.name]
417417 self.emitter.emit(LDA(Absolute(src_label)))
418418 self.emitter.emit(STA(self.addressing_mode_for_index(dest.index)(dest_label)))
419419 self.emitter.emit(LDA(Absolute(Offset(src_label, 1))))
420 self.emitter.emit(STA(self.addressing_mode_for_index(dest.index)(Offset(dest_label, 256))))
421 elif isinstance(src.type, RoutineType) and isinstance(dest.ref.type, TableType) and isinstance(dest.ref.type.of_type, VectorType):
422 src_label = self.labels[src.name]
423 dest_label = self.labels[dest.ref.name]
424 self.emitter.emit(LDA(Immediate(HighAddressByte(src_label))))
425 self.emitter.emit(STA(self.addressing_mode_for_index(dest.index)(dest_label)))
426 self.emitter.emit(LDA(Immediate(LowAddressByte(src_label))))
420427 self.emitter.emit(STA(self.addressing_mode_for_index(dest.index)(Offset(dest_label, 256))))
421428 else:
422429 raise NotImplementedError
649649 | {
650650 | ld x, 0
651651 | copy bar, one
652 | copy bar, many + x
652653 | copy one, many + x
653654 | copy many + x, one
654655 | call one
655656 | }
656657 = $080D LDX #$00
657 = $080F LDA #$35
658 = $0811 STA $083C
658 = $080F LDA #$3F
659 = $0811 STA $0846
659660 = $0814 LDA #$08
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
669 = $0831 JSR $0838
670 = $0834 RTS
671 = $0835 LDX #$C8
672 = $0837 RTS
673 = $0838 JMP ($083C)
674 = $083B RTS
661 = $0816 STA $0847
662 = $0819 LDA #$3F
663 = $081B STA $0848,X
664 = $081E LDA #$08
665 = $0820 STA $0948,X
666 = $0823 LDA $0846
667 = $0826 STA $0848,X
668 = $0829 LDA $0847
669 = $082C STA $0948,X
670 = $082F LDA $0848,X
671 = $0832 STA $0846
672 = $0835 LDA $0948,X
673 = $0838 STA $0847
674 = $083B JSR $0842
675 = $083E RTS
676 = $083F LDX #$C8
677 = $0841 RTS
678 = $0842 JMP ($0846)
679 = $0845 RTS
675680
676681 ### word operations
677682