1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-07 06:29:32 +00:00

Use right endianness when copying literal word into storage.

This commit is contained in:
Chris Pressey 2017-12-07 16:49:43 +00:00
parent 14494bcdbe
commit ad8e0647a4
5 changed files with 13 additions and 7 deletions

View File

@ -7,6 +7,7 @@ History of SixtyPical
* Add word (constant or memory location) to word memory location.
* Add word to pointer (unchecked for now).
* Implementation: `--debug` shows some extra info during analysis.
* Fixed bug where `copy`ing literal word into word storage used wrong endianness.
0.8
---

View File

@ -83,9 +83,10 @@ routine our_cinv
routine main
inputs cinv
outputs cinv, save_cinv
outputs cinv, save_cinv, pos
trashes a, n, z
{
copy word 0, pos
with interrupts off {
copy cinv, save_cinv
copy our_cinv, cinv

View File

@ -3,5 +3,9 @@
SRC=$1
OUT=/tmp/a-out.prg
bin/sixtypical --analyze --compile --basic-prelude $SRC > $OUT || exit 1
x64 $OUT
if [ -e vicerc ]; then
x64 -config vicerc $OUT
else
x64 $OUT
fi
rm -f $OUT

View File

@ -358,9 +358,9 @@ class Compiler(object):
elif src.type == TYPE_WORD and dest.type == TYPE_WORD:
if isinstance(src, ConstantRef):
dest_label = self.labels[dest.name]
self.emitter.emit(LDA(Immediate(Byte(src.high_byte()))))
self.emitter.emit(STA(Absolute(dest_label)))
self.emitter.emit(LDA(Immediate(Byte(src.low_byte()))))
self.emitter.emit(STA(Absolute(dest_label)))
self.emitter.emit(LDA(Immediate(Byte(src.high_byte()))))
self.emitter.emit(STA(Absolute(Offset(dest_label, 1))))
else:
src_label = self.labels[src.name]

View File

@ -275,9 +275,9 @@ Copy literal word to word.
| outputs bar
| trashes a, n, z
| {
| copy 65535, bar
| copy 2000, bar
| }
= 00c0a9ff8d0bc0a9ff8d0cc060
= 00c0a9d08d0bc0a9078d0cc060
Copy vector to vector.
@ -458,4 +458,4 @@ Note that this is *not* range-checked. (Yet.)
| add ptr, word 1
| copy [ptr] + y, foo
| }
= 00c0a9028d38c0a96b8d39c0a000a93485fea9c085ffa5fe6d38c085fea5ff6d39c085ffa5fe690185fea5ff690085ffb1fe8d36c060
= 00c0a96b8d38c0a9028d39c0a000a93485fea9c085ffa5fe6d38c085fea5ff6d39c085ffa5fe690185fea5ff690085ffb1fe8d36c060