mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Adding a word memory location to another word memory location.
This commit is contained in:
parent
92525fd482
commit
a4fd0e590b
@ -1,6 +1,11 @@
|
||||
History of SixtyPical
|
||||
=====================
|
||||
|
||||
0.9
|
||||
---
|
||||
|
||||
* Add word (constant or memory location) to word memory location.
|
||||
|
||||
0.8
|
||||
---
|
||||
|
||||
|
@ -40,11 +40,11 @@ Documentation
|
||||
TODO
|
||||
----
|
||||
|
||||
### Add 16 bit values.
|
||||
### Operations on 16 bit values
|
||||
|
||||
I guess this means making `add` a bit more like `copy`.
|
||||
Add word (constant or memory location) to pointer. (Not necessarily range-checked yet though.)
|
||||
|
||||
And then: add to pointer. (Not necessarily range-checked yet though.)
|
||||
Compare word (constant or memory location) with memory location or pointer. (Maybe?)
|
||||
|
||||
And then write a little demo "game" where you can move a block around the screen with
|
||||
the joystick.
|
||||
|
@ -147,14 +147,26 @@ class Compiler(object):
|
||||
self.emitter.emit(ADC(Immediate(Byte(src.value))))
|
||||
else:
|
||||
self.emitter.emit(ADC(Absolute(self.labels[src.name])))
|
||||
elif isinstance(src, ConstantRef) and isinstance(dest, LocationRef) and dest.type == TYPE_WORD:
|
||||
dest_label = self.labels[dest.name]
|
||||
self.emitter.emit(LDA(Absolute(dest_label)))
|
||||
self.emitter.emit(ADC(Immediate(Byte(src.low_byte()))))
|
||||
self.emitter.emit(STA(Absolute(dest_label)))
|
||||
self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
|
||||
self.emitter.emit(ADC(Immediate(Byte(src.high_byte()))))
|
||||
self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
|
||||
elif isinstance(dest, LocationRef) and dest.type == TYPE_WORD and src.type == TYPE_WORD:
|
||||
if isinstance(src, ConstantRef):
|
||||
dest_label = self.labels[dest.name]
|
||||
self.emitter.emit(LDA(Absolute(dest_label)))
|
||||
self.emitter.emit(ADC(Immediate(Byte(src.low_byte()))))
|
||||
self.emitter.emit(STA(Absolute(dest_label)))
|
||||
self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
|
||||
self.emitter.emit(ADC(Immediate(Byte(src.high_byte()))))
|
||||
self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
|
||||
elif isinstance(src, LocationRef):
|
||||
src_label = self.labels[src.name]
|
||||
dest_label = self.labels[dest.name]
|
||||
self.emitter.emit(LDA(Absolute(dest_label)))
|
||||
self.emitter.emit(ADC(Absolute(src_label)))
|
||||
self.emitter.emit(STA(Absolute(dest_label)))
|
||||
self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
|
||||
self.emitter.emit(ADC(Absolute(Offset(src_label, 1))))
|
||||
self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
|
||||
else:
|
||||
raise UnsupportedOpcodeError(instr)
|
||||
else:
|
||||
raise UnsupportedOpcodeError(instr)
|
||||
elif opcode == 'sub':
|
||||
|
@ -412,6 +412,34 @@ To be sure, `add`ing a word constant to a word memory location trashes `a`.
|
||||
| }
|
||||
? ForbiddenWriteError: a in main
|
||||
|
||||
You can `add` a word memory location to another word memory location.
|
||||
|
||||
| word score
|
||||
| word delta
|
||||
| routine main
|
||||
| inputs score, delta
|
||||
| outputs score
|
||||
| trashes a, c, z, v, n
|
||||
| {
|
||||
| st off, c
|
||||
| add score, delta
|
||||
| }
|
||||
= ok
|
||||
|
||||
`add`ing a word memory location to a word memory location trashes `a`.
|
||||
|
||||
| word score
|
||||
| word delta
|
||||
| routine main
|
||||
| inputs score, delta
|
||||
| outputs score
|
||||
| trashes c, z, v, n
|
||||
| {
|
||||
| st off, c
|
||||
| add score, delta
|
||||
| }
|
||||
? ForbiddenWriteError: a in main
|
||||
|
||||
### sub ###
|
||||
|
||||
Can't `sub` from or to a memory location that isn't initialized.
|
||||
|
@ -344,11 +344,11 @@ goto.
|
||||
|
||||
### word operations
|
||||
|
||||
Adding a constant word to a memory location.
|
||||
Adding a constant word to a word memory location.
|
||||
|
||||
| word score
|
||||
| routine main
|
||||
| inputs a, score
|
||||
| inputs score
|
||||
| outputs score
|
||||
| trashes a, c, z, v, n
|
||||
| {
|
||||
@ -357,6 +357,20 @@ Adding a constant word to a memory location.
|
||||
| }
|
||||
= 00c018ad12c069cf8d12c0ad13c069078d13c060
|
||||
|
||||
Adding a word memory location to another word memory location.
|
||||
|
||||
| word score
|
||||
| word delta
|
||||
| routine main
|
||||
| inputs score, delta
|
||||
| outputs score
|
||||
| trashes a, c, z, v, n
|
||||
| {
|
||||
| st off, c
|
||||
| add score, delta
|
||||
| }
|
||||
= 00c018ad14c06d16c08d14c0ad15c06d17c08d15c060
|
||||
|
||||
### Buffers and Pointers
|
||||
|
||||
Load address into pointer.
|
||||
|
Loading…
x
Reference in New Issue
Block a user