From b073fe54a00afe0c578ac894a2a1f6c437d968bb Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Tue, 13 Mar 2018 17:49:48 +0000 Subject: [PATCH] Tests for the `downto` variant too. --- tests/SixtyPical Analysis.md | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/SixtyPical Analysis.md b/tests/SixtyPical Analysis.md index 1e50885..fadaa3f 100644 --- a/tests/SixtyPical Analysis.md +++ b/tests/SixtyPical Analysis.md @@ -1709,6 +1709,52 @@ If the range isn't known to be smaller than the final value, you can't go up to | } ? RangeExceededError +In a "for" loop (downto variant), we know the exact range the loop variable takes on. + + | byte table[16] tab + | + | define foo routine inputs tab trashes a, x, c, z, v, n { + | ld x, 15 + | for x downto 0 { + | ld a, tab + x + | } + | } + = ok + + | byte table[15] tab + | + | define foo routine inputs tab trashes a, x, c, z, v, n { + | ld x, 15 + | for x downto 0 { + | ld a, tab + x + | } + | } + ? RangeExceededError + +You cannot modify the loop variable in a "for" loop (downto variant). + + | byte table[16] tab + | + | define foo routine inputs tab trashes a, x, c, z, v, n { + | ld x, 15 + | for x downto 0 { + | ld x, 0 + | } + | } + ? ForbiddenWriteError + +If the range isn't known to be larger than the final value, you can't go down to it. + + | byte table[32] tab + | + | define foo routine inputs tab trashes a, x, c, z, v, n { + | ld x, 0 + | for x downto 0 { + | ld a, tab + x + | } + | } + ? RangeExceededError + ### copy ### Can't `copy` from a memory location that isn't initialized.