mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-25 23:49:17 +00:00
Adding a constant word to a memory location.
This commit is contained in:
parent
cf679b293a
commit
92525fd482
@ -2,7 +2,7 @@ word score
|
||||
routine main
|
||||
inputs score
|
||||
outputs score
|
||||
trashes c, z, v, n
|
||||
trashes a, c, z, v, n
|
||||
{
|
||||
st off, c
|
||||
add score, 1999
|
||||
|
@ -147,6 +147,14 @@ 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))))
|
||||
else:
|
||||
raise UnsupportedOpcodeError(instr)
|
||||
elif opcode == 'sub':
|
||||
@ -318,11 +326,9 @@ class Compiler(object):
|
||||
elif src.type == TYPE_WORD and dest.type == TYPE_WORD:
|
||||
if isinstance(src, ConstantRef):
|
||||
dest_label = self.labels[dest.name]
|
||||
hi = (src.value >> 8) & 255
|
||||
lo = src.value & 255
|
||||
self.emitter.emit(LDA(Immediate(Byte(hi))))
|
||||
self.emitter.emit(LDA(Immediate(Byte(src.high_byte()))))
|
||||
self.emitter.emit(STA(Absolute(dest_label)))
|
||||
self.emitter.emit(LDA(Immediate(Byte(lo))))
|
||||
self.emitter.emit(LDA(Immediate(Byte(src.low_byte()))))
|
||||
self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
|
||||
else:
|
||||
src_label = self.labels[src.name]
|
||||
|
@ -191,6 +191,12 @@ class ConstantRef(Ref):
|
||||
def is_constant(self):
|
||||
return True
|
||||
|
||||
def high_byte(self):
|
||||
return (self.value >> 8) & 255
|
||||
|
||||
def low_byte(self):
|
||||
return self.value & 255
|
||||
|
||||
|
||||
REG_A = LocationRef(TYPE_BYTE, 'a')
|
||||
REG_X = LocationRef(TYPE_BYTE, 'x')
|
||||
|
@ -342,6 +342,21 @@ goto.
|
||||
| }
|
||||
= 00c0a0c84c06c060a2c860
|
||||
|
||||
### word operations
|
||||
|
||||
Adding a constant word to a memory location.
|
||||
|
||||
| word score
|
||||
| routine main
|
||||
| inputs a, score
|
||||
| outputs score
|
||||
| trashes a, c, z, v, n
|
||||
| {
|
||||
| st off, c
|
||||
| add score, 1999
|
||||
| }
|
||||
= 00c018ad12c069cf8d12c0ad13c069078d13c060
|
||||
|
||||
### Buffers and Pointers
|
||||
|
||||
Load address into pointer.
|
||||
|
Loading…
Reference in New Issue
Block a user