git @ Cat's Eye Technologies SixtyPical / 92db4ac
More tests for "for" loops. Chris Pressey 3 years ago
1 changed file(s) with 61 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
18071807 | }
18081808 ? UnmeaningfulReadError
18091809
1810 Because routines current do not express range constraints, It may not do to take the loop variable as an input. (?)
1810 Because routines currently do not include range constraints,
1811 the loop variable may not be useful as an input (the location
1812 is assumed to have the maximum range.)
18111813
18121814 | byte table[16] tab
18131815 |
19241926 | }
19251927 ? UnmeaningfulReadError: y
19261928
1929 The "for" loop does not preserve the `z` or `n` registers.
1930
1931 | define foo routine trashes x {
1932 | ld x, 0
1933 | for x up to 15 {
1934 | }
1935 | }
1936 ? ForbiddenWriteError
1937
1938 But it does preserve the other registers, such as `c`.
1939
1940 | define foo routine trashes x, z, n {
1941 | ld x, 0
1942 | for x up to 15 {
1943 | }
1944 | }
1945 = ok
1946
1947 In fact it does not strictly trash `z` and `n`, as they are
1948 always set to known values after the loop. TODO: document
1949 what these known values are!
1950
1951 | define foo routine outputs z, n trashes x {
1952 | ld x, 0
1953 | for x up to 15 {
1954 | }
1955 | }
1956 = ok
1957
19271958 #### downward-counting variant
19281959
19291960 In a "for" loop (downward-counting variant), we know the exact range the loop variable takes on.
19822013 | }
19832014 | }
19842015 ? RangeExceededError
2016
2017 The "for" loop does not preserve the `z` or `n` registers.
2018
2019 | define foo routine trashes x {
2020 | ld x, 15
2021 | for x down to 0 {
2022 | }
2023 | }
2024 ? ForbiddenWriteError
2025
2026 But it does preserve the other registers, such as `c`.
2027
2028 | define foo routine trashes x, z, n {
2029 | ld x, 15
2030 | for x down to 0 {
2031 | }
2032 | }
2033 = ok
2034
2035 In fact it does not strictly trash `z` and `n`, as they are
2036 always set to known values after the loop. TODO: document
2037 what these known values are!
2038
2039 | define foo routine outputs z, n trashes x {
2040 | ld x, 15
2041 | for x down to 0 {
2042 | }
2043 | }
2044 = ok
19852045
19862046 ### save ###
19872047