Adding a word memory location to another word memory location.
Chris Pressey
7 years ago
0 | 0 | History of SixtyPical |
1 | 1 | ===================== |
2 | ||
3 | 0.9 | |
4 | --- | |
5 | ||
6 | * Add word (constant or memory location) to word memory location. | |
2 | 7 | |
3 | 8 | 0.8 |
4 | 9 | --- |
39 | 39 | TODO |
40 | 40 | ---- |
41 | 41 | |
42 | ### Add 16 bit values. | |
42 | ### Operations on 16 bit values | |
43 | 43 | |
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.) | |
45 | 45 | |
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?) | |
47 | 47 | |
48 | 48 | And then write a little demo "game" where you can move a block around the screen with |
49 | 49 | the joystick. |
146 | 146 | self.emitter.emit(ADC(Immediate(Byte(src.value)))) |
147 | 147 | else: |
148 | 148 | 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) | |
157 | 169 | else: |
158 | 170 | raise UnsupportedOpcodeError(instr) |
159 | 171 | elif opcode == 'sub': |
408 | 408 | | { |
409 | 409 | | st off, c |
410 | 410 | | 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 | |
411 | 439 | | } |
412 | 440 | ? ForbiddenWriteError: a in main |
413 | 441 |
343 | 343 | |
344 | 344 | ### word operations |
345 | 345 | |
346 | Adding a constant word to a memory location. | |
346 | Adding a constant word to a word memory location. | |
347 | 347 | |
348 | 348 | | word score |
349 | 349 | | routine main |
350 | | inputs a, score | |
350 | | inputs score | |
351 | 351 | | outputs score |
352 | 352 | | trashes a, c, z, v, n |
353 | 353 | | { |
355 | 355 | | add score, 1999 |
356 | 356 | | } |
357 | 357 | = 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 | |
358 | 372 | |
359 | 373 | ### Buffers and Pointers |
360 | 374 |