1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-04-27 17:44:49 +00:00

Fix problem with test case, and with serializing as zero page.

This commit is contained in:
Chris Pressey 2017-11-24 13:42:14 +00:00
parent e41dd1aa01
commit c8c69a2a7d
4 changed files with 30 additions and 16 deletions

12
eg/buffer.60p Normal file
View File

@ -0,0 +1,12 @@
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
}

View File

@ -301,12 +301,11 @@ class Compiler(object):
elif isinstance(src.type, BufferType) and isinstance(dest.type, PointerType):
# TODO: this maybe should not be the 'copy' opcode at all that means this
src_label = self.labels[src.name]
dest_label = self.labels[dest.name]
dest_label = self.labels[dest.name]
self.emitter.emit(LDA(Immediate(HighAddressByte(src_label))))
self.emitter.emit(STA(ZeroPage(dest_label)))
self.emitter.emit(LDA(Immediate(LowAddressByte(src_label))))
#self.emitter.emit(STA(ZeroPage(Offset(dest_label, 1))))
self.emitter.emit(STA(ZeroPage(dest_label)))
self.emitter.emit(STA(ZeroPage(Offset(dest_label, 1))))
elif isinstance(src.type, VectorType) and isinstance(dest.type, VectorType):
src_label = self.labels[src.name]
dest_label = self.labels[dest.name]

View File

@ -82,6 +82,9 @@ class Offset(Emittable):
def serialize(self, addr=None):
return self.label.serialize(offset=self.offset)
def serialize_as_zero_page(self, offset=0):
return self.label.serialize_as_zero_page(offset=self.offset)
def __repr__(self):
return "%s(%r, %r)" % (self.__class__.__name__, self.label, self.offset)

View File

@ -344,16 +344,16 @@ goto.
Buffers and pointers.
> | 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
> | }
> = 00c0a000a90b850dc0a9c0850ec060
| 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
| }
= 00c0a000a90b85fea9c085ff60