git @ Cat's Eye Technologies SixtyPical / e7674c4
Confirm constraint on `save`ing `a`. Chris Pressey 3 years ago
2 changed file(s) with 16 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
784784 baton = batons.pop()
785785 context.re_introduce(baton)
786786
787 # FIXME check if A needs to be the outer thing that is saved, I think it does.
787 # We do this check outside the loop, because A is only preserved
788 # if it is the outermost thing being `save`d.
788789 if location == REG_A:
789790 pass
790791 else:
21202120 | }
21212121 = ok
21222122
2123 `a` is only preserved if it is the outermost thing `save`d.
2124
2125 | routine main
2126 | inputs a
2127 | outputs a
2128 | trashes z, n
2129 | {
2130 | save x, a {
2131 | ld a, 0
2132 | ld x, 1
2133 | }
2134 | }
2135 ? UnmeaningfulOutputError: a
2136
21232137 Not just registers, but also user-defined locations can be saved.
21242138
21252139 | byte foo