Confirm constraint on `save`ing `a`.
Chris Pressey
3 years ago
784 | 784 | baton = batons.pop() |
785 | 785 | context.re_introduce(baton) |
786 | 786 | |
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. | |
788 | 789 | if location == REG_A: |
789 | 790 | pass |
790 | 791 | else: |
2120 | 2120 | | } |
2121 | 2121 | = ok |
2122 | 2122 | |
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 | ||
2123 | 2137 | Not just registers, but also user-defined locations can be saved. |
2124 | 2138 | |
2125 | 2139 | | byte foo |