mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-19 20:30:45 +00:00
copy from word storage to word table and back, indexed by x or y.
This commit is contained in:
parent
b86e7491d5
commit
2216fcec17
@ -6,7 +6,8 @@ History of SixtyPical
|
|||||||
|
|
||||||
* Add word (constant or memory location) to word memory location.
|
* Add word (constant or memory location) to word memory location.
|
||||||
* Add word to pointer (unchecked for now).
|
* Add word to pointer (unchecked for now).
|
||||||
* Adding `word table` type (in progress).
|
* Added `word table` type.
|
||||||
|
* Can `copy` from word storage location to word table and back.
|
||||||
* Implementation: `--debug` shows some extra info during analysis.
|
* Implementation: `--debug` shows some extra info during analysis.
|
||||||
* Fixed bug where `copy`ing literal word into word storage used wrong endianness.
|
* Fixed bug where `copy`ing literal word into word storage used wrong endianness.
|
||||||
* Fixed bug where every memory location was allocated 2 bytes of storage, regardless of type.
|
* Fixed bug where every memory location was allocated 2 bytes of storage, regardless of type.
|
||||||
|
@ -4,10 +4,13 @@ word table many
|
|||||||
routine main
|
routine main
|
||||||
inputs one, many
|
inputs one, many
|
||||||
outputs one, many
|
outputs one, many
|
||||||
trashes a, x, n, z
|
trashes a, x, y, n, z
|
||||||
{
|
{
|
||||||
ld x, 0
|
ld x, 0
|
||||||
|
ld y, 0
|
||||||
copy 777, one
|
copy 777, one
|
||||||
copy one, many + x
|
copy one, many + x
|
||||||
//copy many + x, one
|
copy one, many + y
|
||||||
|
copy many + x, one
|
||||||
|
copy many + y, one
|
||||||
}
|
}
|
||||||
|
@ -371,9 +371,26 @@ class Compiler(object):
|
|||||||
else:
|
else:
|
||||||
raise NotImplementedError(dest)
|
raise NotImplementedError(dest)
|
||||||
self.emitter.emit(LDA(Absolute(src_label)))
|
self.emitter.emit(LDA(Absolute(src_label)))
|
||||||
self.emitter.emit(STA(AbsoluteX(dest_label)))
|
self.emitter.emit(STA(addressing_mode(dest_label)))
|
||||||
self.emitter.emit(LDA(Absolute(Offset(src_label, 1))))
|
self.emitter.emit(LDA(Absolute(Offset(src_label, 1))))
|
||||||
self.emitter.emit(STA(AbsoluteX(Offset(dest_label, 256))))
|
self.emitter.emit(STA(addressing_mode(Offset(dest_label, 256))))
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
elif isinstance(src, IndexedRef) and isinstance(dest, LocationRef):
|
||||||
|
if src.ref.type == TYPE_WORD_TABLE and dest.type == TYPE_WORD:
|
||||||
|
src_label = self.labels[src.ref.name]
|
||||||
|
dest_label = self.labels[dest.name]
|
||||||
|
addressing_mode = None
|
||||||
|
if src.index == REG_X:
|
||||||
|
addressing_mode = AbsoluteX
|
||||||
|
elif src.index == REG_Y:
|
||||||
|
addressing_mode = AbsoluteY
|
||||||
|
else:
|
||||||
|
raise NotImplementedError(src)
|
||||||
|
self.emitter.emit(LDA(addressing_mode(src_label)))
|
||||||
|
self.emitter.emit(STA(Absolute(dest_label)))
|
||||||
|
self.emitter.emit(LDA(addressing_mode(Offset(src_label, 256))))
|
||||||
|
self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ Copy routine to vector, inside an `interrupts off` block.
|
|||||||
= $081A INX
|
= $081A INX
|
||||||
= $081B RTS
|
= $081B RTS
|
||||||
|
|
||||||
Copy word to word table.
|
Copy word to word table and back, with both `x` and `y` as indexes.
|
||||||
|
|
||||||
| word one
|
| word one
|
||||||
| word table many
|
| word table many
|
||||||
@ -461,22 +461,39 @@ Copy word to word table.
|
|||||||
| routine main
|
| routine main
|
||||||
| inputs one, many
|
| inputs one, many
|
||||||
| outputs one, many
|
| outputs one, many
|
||||||
| trashes a, x, n, z
|
| trashes a, x, y, n, z
|
||||||
| {
|
| {
|
||||||
| ld x, 0
|
| ld x, 0
|
||||||
|
| ld y, 0
|
||||||
| copy 777, one
|
| copy 777, one
|
||||||
| copy one, many + x
|
| copy one, many + x
|
||||||
|
| copy one, many + y
|
||||||
|
| copy many + x, one
|
||||||
|
| copy many + y, one
|
||||||
| }
|
| }
|
||||||
= $080D LDX #$00
|
= $080D LDX #$00
|
||||||
= $080F LDA #$09
|
= $080F LDY #$00
|
||||||
= $0811 STA $0826
|
= $0811 LDA #$09
|
||||||
= $0814 LDA #$03
|
= $0813 STA $084C
|
||||||
= $0816 STA $0827
|
= $0816 LDA #$03
|
||||||
= $0819 LDA $0826
|
= $0818 STA $084D
|
||||||
= $081C STA $0828,X
|
= $081B LDA $084C
|
||||||
= $081F LDA $0827
|
= $081E STA $084E,X
|
||||||
= $0822 STA $0928,X
|
= $0821 LDA $084D
|
||||||
= $0825 RTS
|
= $0824 STA $094E,X
|
||||||
|
= $0827 LDA $084C
|
||||||
|
= $082A STA $084E,Y
|
||||||
|
= $082D LDA $084D
|
||||||
|
= $0830 STA $094E,Y
|
||||||
|
= $0833 LDA $084E,X
|
||||||
|
= $0836 STA $084C
|
||||||
|
= $0839 LDA $094E,X
|
||||||
|
= $083C STA $084D
|
||||||
|
= $083F LDA $084E,Y
|
||||||
|
= $0842 STA $084C
|
||||||
|
= $0845 LDA $094E,Y
|
||||||
|
= $0848 STA $084D
|
||||||
|
= $084B RTS
|
||||||
|
|
||||||
Indirect call.
|
Indirect call.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user