git @ Cat's Eye Technologies SixtyPical / 19461bc
Support `save X, Y, Z {}` as a shortcut syntax for nested `save`s. Chris Pressey 3 years ago
3 changed file(s) with 33 addition(s) and 39 deletion(s). Raw diff Collapse all Expand all
33 0.17
44 ----
55
6 * `save X, Y, Z { }` now allowed as a shortcut for nested `save`s.
67 * Split TODO off into own file.
78 * `sixtypical` no longer writes the compiled binary to standard
8 output. The `--output` command-line argument should be given.
9 output. The `--output` command-line argument should be given
10 to get a compiled binary; otherwise only analysis is run.
11 * Internal cleanups, including a hierarchy of `Outputters`.
912 * All tests pass when `sixtypical` is run under Python 3.5.2.
1013
1114 0.16
1414 Is that consistent with `st`? Well, probably it is, but we have to explain it.
1515 It might make more sense, then, for it to be "part of the operation" instead of "part of
1616 the reference"; something like `st.hi x, word`; `st.lo y, word`. Dunno.
17
18 ### Save multiple values in single block
19
20 As a shortcut for the idiom
21
22 save a { save var {
23 ...
24 } }
25
26 allow
27
28 save a, var {
29 ...
30 }
3117
3218 ### Save values to other-than-the-stack
3319
617617 self.emitter.emit(CLI())
618618
619619 def compile_save(self, instr):
620 location = instr.locations[0]
621 if location == REG_A:
622 self.emitter.emit(PHA())
623 self.compile_block(instr.block)
624 self.emitter.emit(PLA())
625 elif location == REG_X:
626 self.emitter.emit(TXA())
627 self.emitter.emit(PHA())
628 self.compile_block(instr.block)
629 self.emitter.emit(PLA())
630 self.emitter.emit(TAX())
631 elif location == REG_Y:
632 self.emitter.emit(TYA())
633 self.emitter.emit(PHA())
634 self.compile_block(instr.block)
635 self.emitter.emit(PLA())
636 self.emitter.emit(TAY())
637 else:
638 src_label = self.get_label(location.name)
639 self.emitter.emit(LDA(Absolute(src_label)))
640 self.emitter.emit(PHA())
641 self.compile_block(instr.block)
642 self.emitter.emit(PLA())
643 self.emitter.emit(STA(Absolute(src_label)))
620 for location in instr.locations:
621 if location == REG_A:
622 self.emitter.emit(PHA())
623 elif location == REG_X:
624 self.emitter.emit(TXA())
625 self.emitter.emit(PHA())
626 elif location == REG_Y:
627 self.emitter.emit(TYA())
628 self.emitter.emit(PHA())
629 else:
630 src_label = self.get_label(location.name)
631 self.emitter.emit(LDA(Absolute(src_label)))
632 self.emitter.emit(PHA())
633
634 self.compile_block(instr.block)
635
636 for location in reversed(instr.locations):
637 if location == REG_A:
638 self.emitter.emit(PLA())
639 elif location == REG_X:
640 self.emitter.emit(PLA())
641 self.emitter.emit(TAX())
642 elif location == REG_Y:
643 self.emitter.emit(PLA())
644 self.emitter.emit(TAY())
645 else:
646 src_label = self.get_label(location.name)
647 self.emitter.emit(PLA())
648 self.emitter.emit(STA(Absolute(src_label)))