git @ Cat's Eye Technologies SixtyPical / a4fd0e5
Adding a word memory location to another word memory location. Chris Pressey 7 years ago
5 changed file(s) with 72 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
00 History of SixtyPical
11 =====================
2
3 0.9
4 ---
5
6 * Add word (constant or memory location) to word memory location.
27
38 0.8
49 ---
3939 TODO
4040 ----
4141
42 ### Add 16 bit values.
42 ### Operations on 16 bit values
4343
44 I guess this means making `add` a bit more like `copy`.
44 Add word (constant or memory location) to pointer. (Not necessarily range-checked yet though.)
4545
46 And then: add to pointer. (Not necessarily range-checked yet though.)
46 Compare word (constant or memory location) with memory location or pointer. (Maybe?)
4747
4848 And then write a little demo "game" where you can move a block around the screen with
4949 the joystick.
146146 self.emitter.emit(ADC(Immediate(Byte(src.value))))
147147 else:
148148 self.emitter.emit(ADC(Absolute(self.labels[src.name])))
149 elif isinstance(src, ConstantRef) and isinstance(dest, LocationRef) and dest.type == TYPE_WORD:
150 dest_label = self.labels[dest.name]
151 self.emitter.emit(LDA(Absolute(dest_label)))
152 self.emitter.emit(ADC(Immediate(Byte(src.low_byte()))))
153 self.emitter.emit(STA(Absolute(dest_label)))
154 self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
155 self.emitter.emit(ADC(Immediate(Byte(src.high_byte()))))
156 self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
149 elif isinstance(dest, LocationRef) and dest.type == TYPE_WORD and src.type == TYPE_WORD:
150 if isinstance(src, ConstantRef):
151 dest_label = self.labels[dest.name]
152 self.emitter.emit(LDA(Absolute(dest_label)))
153 self.emitter.emit(ADC(Immediate(Byte(src.low_byte()))))
154 self.emitter.emit(STA(Absolute(dest_label)))
155 self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
156 self.emitter.emit(ADC(Immediate(Byte(src.high_byte()))))
157 self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
158 elif isinstance(src, LocationRef):
159 src_label = self.labels[src.name]
160 dest_label = self.labels[dest.name]
161 self.emitter.emit(LDA(Absolute(dest_label)))
162 self.emitter.emit(ADC(Absolute(src_label)))
163 self.emitter.emit(STA(Absolute(dest_label)))
164 self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
165 self.emitter.emit(ADC(Absolute(Offset(src_label, 1))))
166 self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
167 else:
168 raise UnsupportedOpcodeError(instr)
157169 else:
158170 raise UnsupportedOpcodeError(instr)
159171 elif opcode == 'sub':
408408 | {
409409 | st off, c
410410 | add score, 1999
411 | }
412 ? ForbiddenWriteError: a in main
413
414 You can `add` a word memory location to another word memory location.
415
416 | word score
417 | word delta
418 | routine main
419 | inputs score, delta
420 | outputs score
421 | trashes a, c, z, v, n
422 | {
423 | st off, c
424 | add score, delta
425 | }
426 = ok
427
428 `add`ing a word memory location to a word memory location trashes `a`.
429
430 | word score
431 | word delta
432 | routine main
433 | inputs score, delta
434 | outputs score
435 | trashes c, z, v, n
436 | {
437 | st off, c
438 | add score, delta
411439 | }
412440 ? ForbiddenWriteError: a in main
413441
343343
344344 ### word operations
345345
346 Adding a constant word to a memory location.
346 Adding a constant word to a word memory location.
347347
348348 | word score
349349 | routine main
350 | inputs a, score
350 | inputs score
351351 | outputs score
352352 | trashes a, c, z, v, n
353353 | {
355355 | add score, 1999
356356 | }
357357 = 00c018ad12c069cf8d12c0ad13c069078d13c060
358
359 Adding a word memory location to another word memory location.
360
361 | word score
362 | word delta
363 | routine main
364 | inputs score, delta
365 | outputs score
366 | trashes a, c, z, v, n
367 | {
368 | st off, c
369 | add score, delta
370 | }
371 = 00c018ad14c06d16c08d14c0ad15c06d17c08d15c060
358372
359373 ### Buffers and Pointers
360374