diff --git a/src/sixtypical/analyzer.py b/src/sixtypical/analyzer.py index df7b3da..1e69965 100644 --- a/src/sixtypical/analyzer.py +++ b/src/sixtypical/analyzer.py @@ -785,7 +785,8 @@ class Analyzer(object): baton = batons.pop() context.re_introduce(baton) - # FIXME check if A needs to be the outer thing that is saved, I think it does. + # We do this check outside the loop, because A is only preserved + # if it is the outermost thing being `save`d. if location == REG_A: pass else: diff --git a/tests/SixtyPical Analysis.md b/tests/SixtyPical Analysis.md index 7dd97b1..0caecc8 100644 --- a/tests/SixtyPical Analysis.md +++ b/tests/SixtyPical Analysis.md @@ -2121,6 +2121,20 @@ There is a shortcut syntax for a nested series of `save`s. | } = ok +`a` is only preserved if it is the outermost thing `save`d. + + | routine main + | inputs a + | outputs a + | trashes z, n + | { + | save x, a { + | ld a, 0 + | ld x, 1 + | } + | } + ? UnmeaningfulOutputError: a + Not just registers, but also user-defined locations can be saved. | byte foo