git @ Cat's Eye Technologies SixtyPical / e2daa33
Compile copy byte to byte and word to word. Chris Pressey 9 years ago
4 changed file(s) with 46 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
44 -------
55
66 * User-defined `byte` locations can be given an initial value.
7 * `word` type locations which can be defined and `copy`ed between.
8 * Can `copy` directly from one user-defined `byte` location to another.
79
810 0.6
911 ---
4343
4444 For 0.7:
4545
46 * `word` type.
46 * `low` and `high` address operators (turn `word` type into `byte`.)
4747 * `word table` type.
4848
4949 For 0.8:
22 from sixtypical.ast import Program, Routine, Block, Instr
33 from sixtypical.model import (
44 ConstantRef,
5 TYPE_BIT,
5 TYPE_BIT, TYPE_BYTE, TYPE_WORD,
66 RoutineType, VectorType,
77 REG_A, REG_X, REG_Y, FLAG_C
88 )
274274 self.compile_block(instr.block)
275275 self.emitter.emit(CLI())
276276 elif opcode == 'copy':
277 if isinstance(src.type, VectorType) and isinstance(dest.type, VectorType):
277 if src.type == TYPE_BYTE and dest.type == TYPE_BYTE:
278 src_label = self.labels[src.name]
279 dest_label = self.labels[dest.name]
280 self.emitter.emit(LDA(Absolute(src_label)))
281 self.emitter.emit(STA(Absolute(dest_label)))
282 elif src.type == TYPE_WORD and dest.type == TYPE_WORD:
283 src_label = self.labels[src.name]
284 dest_label = self.labels[dest.name]
285 self.emitter.emit(LDA(Absolute(src_label)))
286 self.emitter.emit(STA(Absolute(dest_label)))
287 self.emitter.emit(LDA(Absolute(Offset(src_label, 1))))
288 self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
289 elif isinstance(src.type, VectorType) and isinstance(dest.type, VectorType):
278290 src_label = self.labels[src.name]
279291 dest_label = self.labels[dest.name]
280292 self.emitter.emit(LDA(Absolute(src_label)))
238238 | }
239239 = 00c0a200a9009d0dc0bd0dc060
240240
241 Copy instruction..
241 Copy byte to byte.
242
243 | byte bar
244 | byte baz
245 |
246 | routine main
247 | inputs baz
248 | outputs bar
249 | trashes a, n, z
250 | {
251 | copy baz, bar
252 | }
253 = 00c0ad09c08d07c060
254
255 Copy word to word.
256
257 | word bar
258 | word baz
259 |
260 | routine main
261 | inputs baz
262 | outputs bar
263 | trashes a, n, z
264 | {
265 | copy baz, bar
266 | }
267 = 00c0ad0fc08d0dc0ad10c08d0ec060
268
269 Copy vector to vector.
242270
243271 | vector bar
244272 | vector baz