git @ Cat's Eye Technologies SixtyPical / 63f75a2
Initialized `word` type memory locations. Chris Pressey 3 years ago
5 changed file(s) with 48 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
66 * Can `call` and `goto` routines that are defined further down in the source code.
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.
9 * Initialized `word` memory locations.
910 * Fixed bug which was preventing `if` branches to diverge in what they initialized,
1011 if it was already initialized when going into the `if`.
1112 * Fixed a bug which was making it crash when trying to analyze `repeat forever` loops.
7575 * always analyze before executing or compiling, unless told not to
7676 * `trash` instruction.
7777 * `interrupt` routines -- to indicate that "the supervisor" has stored values on the stack, so we can trash them.
78 * pre-initialized `word` variables
7978 * error messages that include the line number of the source code
8079 * have `copy` instruction able to copy a byte to a user-def mem loc, etc.
8180 * add absolute addressing in shl/shr, absolute-indexed for add, sub, etc.
55 TYPE_BIT, TYPE_BYTE, TYPE_BYTE_TABLE, TYPE_WORD, TYPE_WORD_TABLE, BufferType, PointerType, RoutineType, VectorType,
66 REG_A, REG_X, REG_Y, FLAG_C
77 )
8 from sixtypical.emitter import Byte, Label, Offset, LowAddressByte, HighAddressByte
8 from sixtypical.emitter import Byte, Word, Label, Offset, LowAddressByte, HighAddressByte
99 from sixtypical.gen6502 import (
1010 Immediate, Absolute, AbsoluteX, AbsoluteY, ZeroPage, Indirect, IndirectY, Relative,
1111 LDA, LDX, LDY, STA, STX, STY,
7171 for defn in program.defns:
7272 if defn.initial is not None:
7373 label = self.labels[defn.name]
74 initial_data = Byte(defn.initial) # TODO: support other types than Byte
74 initial_data = None
75 type_ = defn.location.type
76 if type_ == TYPE_BYTE:
77 initial_data = Byte(defn.initial)
78 elif type_ == TYPE_WORD:
79 initial_data = Word(defn.initial)
80 else:
81 raise NotImplementedError(type_)
7582 label.set_length(initial_data.size())
7683 self.emitter.resolve_label(label)
7784 self.emitter.emit(initial_data)
8585 | trashes x, z, n
8686 | {
8787 | ld x, 0
88 | }
89 = ok
90
91 If a routine reads or writes a user-define memory location, it needs to declare that too.
92
93 | byte b1 @ 60000
94 | byte b2 : 3
95 | word w1 @ 60001
96 | word w2 : 2000
97 |
98 | routine main
99 | inputs b1, w1
100 | outputs b2, w2
101 | trashes a, z, n
102 | {
103 | ld a, b1
104 | st a, b2
105 | copy w1, w2
88106 | }
89107 = ok
90108
115115 = $080D LDA $0811
116116 = $0810 RTS
117117 = $0811 .byte $03
118
119 Word memory locations with explicit address, initial value.
120
121 | word w1 @ 60001
122 | word w2 : 3003
123 |
124 | routine main
125 | inputs w1
126 | outputs w2
127 | trashes a, z, n
128 | {
129 | copy w1, w2
130 | }
131 = $080D LDA $EA61
132 = $0810 STA $081A
133 = $0813 LDA $EA62
134 = $0816 STA $081B
135 = $0819 RTS
136 = $081A .byte $BB
137 = $081B .byte $0B
118138
119139 Some instructions.
120140