mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-25 23:49:17 +00:00
Compile copy[]+y.
This commit is contained in:
parent
c8c69a2a7d
commit
19a196f765
@ -8,5 +8,5 @@ routine main
|
|||||||
{
|
{
|
||||||
ld y, 0
|
ld y, 0
|
||||||
copy buf, ptr
|
copy buf, ptr
|
||||||
// copy 123, [ptr] + y
|
copy 123, [ptr] + y
|
||||||
}
|
}
|
||||||
|
@ -322,5 +322,15 @@ class Compiler(object):
|
|||||||
self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
|
self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(src.type)
|
raise NotImplementedError(src.type)
|
||||||
|
elif opcode == 'copy[]+y':
|
||||||
|
if src.type == TYPE_BYTE and isinstance(dest.type, PointerType):
|
||||||
|
if isinstance(src, ConstantRef):
|
||||||
|
dest_label = self.labels[dest.name]
|
||||||
|
self.emitter.emit(LDA(Immediate(Byte(src.value))))
|
||||||
|
self.emitter.emit(STA(IndirectY(dest_label)))
|
||||||
|
else:
|
||||||
|
raise NotImplementedError((src.type, dest.type))
|
||||||
|
else:
|
||||||
|
raise NotImplementedError((src.type, dest.type))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(opcode)
|
raise NotImplementedError(opcode)
|
||||||
|
@ -82,16 +82,8 @@ class Indirect(AddressingMode):
|
|||||||
return self.value.serialize()
|
return self.value.serialize()
|
||||||
|
|
||||||
|
|
||||||
class IndirectY(AddressingMode):
|
class IndirectY(ZeroPage):
|
||||||
def __init__(self, value):
|
pass
|
||||||
assert isinstance(value, Label)
|
|
||||||
self.value = value
|
|
||||||
|
|
||||||
def size(self):
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def serialize(self, addr=None):
|
|
||||||
return self.value.serialize()
|
|
||||||
|
|
||||||
|
|
||||||
class Relative(AddressingMode):
|
class Relative(AddressingMode):
|
||||||
|
@ -354,6 +354,21 @@ Buffers and pointers.
|
|||||||
| {
|
| {
|
||||||
| ld y, 0
|
| ld y, 0
|
||||||
| copy buf, ptr
|
| copy buf, ptr
|
||||||
| // copy 123, [ptr] + y
|
|
||||||
| }
|
| }
|
||||||
= 00c0a000a90b85fea9c085ff60
|
= 00c0a000a90b85fea9c085ff60
|
||||||
|
|
||||||
|
Writing through a pointer.
|
||||||
|
|
||||||
|
| buffer[2048] buf
|
||||||
|
| pointer ptr @ 254
|
||||||
|
|
|
||||||
|
| routine main
|
||||||
|
| inputs buf
|
||||||
|
| outputs buf, y
|
||||||
|
| trashes a, z, n, ptr
|
||||||
|
| {
|
||||||
|
| ld y, 0
|
||||||
|
| copy buf, ptr
|
||||||
|
| copy 123, [ptr] + y
|
||||||
|
| }
|
||||||
|
= 00c0a000a90f85fea9c085ffa97b91fe60
|
||||||
|
Loading…
Reference in New Issue
Block a user