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

Support save X, Y, Z {} as a shortcut syntax for nested saves.

This commit is contained in:
Chris Pressey 2018-09-07 11:27:42 +01:00
parent b63bcfcd2b
commit 19461bc205
3 changed files with 33 additions and 39 deletions

View File

@ -4,9 +4,12 @@ History of SixtyPical
0.17
----
* `save X, Y, Z { }` now allowed as a shortcut for nested `save`s.
* Split TODO off into own file.
* `sixtypical` no longer writes the compiled binary to standard
output. The `--output` command-line argument should be given.
output. The `--output` command-line argument should be given
to get a compiled binary; otherwise only analysis is run.
* Internal cleanups, including a hierarchy of `Outputters`.
* All tests pass when `sixtypical` is run under Python 3.5.2.
0.16

14
TODO.md
View File

@ -16,20 +16,6 @@ Is that consistent with `st`? Well, probably it is, but we have to explain it.
It might make more sense, then, for it to be "part of the operation" instead of "part of
the reference"; something like `st.hi x, word`; `st.lo y, word`. Dunno.
### Save multiple values in single block
As a shortcut for the idiom
save a { save var {
...
} }
allow
save a, var {
...
}
### Save values to other-than-the-stack
Allow

View File

@ -618,27 +618,32 @@ class Compiler(object):
self.emitter.emit(CLI())
def compile_save(self, instr):
location = instr.locations[0]
if location == REG_A:
self.emitter.emit(PHA())
self.compile_block(instr.block)
self.emitter.emit(PLA())
elif location == REG_X:
self.emitter.emit(TXA())
self.emitter.emit(PHA())
self.compile_block(instr.block)
self.emitter.emit(PLA())
self.emitter.emit(TAX())
elif location == REG_Y:
self.emitter.emit(TYA())
self.emitter.emit(PHA())
self.compile_block(instr.block)
self.emitter.emit(PLA())
self.emitter.emit(TAY())
else:
src_label = self.get_label(location.name)
self.emitter.emit(LDA(Absolute(src_label)))
self.emitter.emit(PHA())
self.compile_block(instr.block)
self.emitter.emit(PLA())
self.emitter.emit(STA(Absolute(src_label)))
for location in instr.locations:
if location == REG_A:
self.emitter.emit(PHA())
elif location == REG_X:
self.emitter.emit(TXA())
self.emitter.emit(PHA())
elif location == REG_Y:
self.emitter.emit(TYA())
self.emitter.emit(PHA())
else:
src_label = self.get_label(location.name)
self.emitter.emit(LDA(Absolute(src_label)))
self.emitter.emit(PHA())
self.compile_block(instr.block)
for location in reversed(instr.locations):
if location == REG_A:
self.emitter.emit(PLA())
elif location == REG_X:
self.emitter.emit(PLA())
self.emitter.emit(TAX())
elif location == REG_Y:
self.emitter.emit(PLA())
self.emitter.emit(TAY())
else:
src_label = self.get_label(location.name)
self.emitter.emit(PLA())
self.emitter.emit(STA(Absolute(src_label)))