diff --git a/HISTORY.md b/HISTORY.md index df6ec64..776ab73 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,6 +8,7 @@ History of SixtyPical * Initialized `byte table` values need not have all 256 bytes initialized. * Constraints for `vector` type come immediately after the type, not the variable. * `vector table` storage, and ability to copy vectors in and out of same. +* Fixed bug where index register wasn't required to be initialized before table access. 0.10 ---- diff --git a/src/sixtypical/analyzer.py b/src/sixtypical/analyzer.py index 2abc5b3..2320dbd 100644 --- a/src/sixtypical/analyzer.py +++ b/src/sixtypical/analyzer.py @@ -238,6 +238,7 @@ class Analyzer(object): raise TypeMismatchError('%s and %s in %s' % (src.name, dest.name, self.current_routine.name) ) + context.assert_meaningful(instr.index) elif src.type != dest.type: raise TypeMismatchError('%s and %s in %s' % (src.name, dest.name, self.current_routine.name) @@ -250,6 +251,7 @@ class Analyzer(object): pass else: raise TypeMismatchError((src, dest)) + context.assert_meaningful(instr.index) elif src.type != dest.type: raise TypeMismatchError('%s and %s in %s' % (src.name, dest.name, self.current_routine.name) diff --git a/tests/SixtyPical Analysis.md b/tests/SixtyPical Analysis.md index 4f27f5e..51032b7 100644 --- a/tests/SixtyPical Analysis.md +++ b/tests/SixtyPical Analysis.md @@ -240,7 +240,7 @@ Can't `st` a `word` type. ### tables ### -Storing to a table, you must use an index, and vice-versa. +Storing to a table, you must use an index. | byte one | byte table[256] many @@ -294,7 +294,21 @@ Storing to a table, you must use an index, and vice-versa. | } = ok -Reading from a table, you must use an index, and vice-versa. +The index must be initialized. + + | byte one + | byte table[256] many + | + | routine main + | outputs many + | trashes a, x, n, z + | { + | ld a, 0 + | st a, many + x + | } + ? UnmeaningfulReadError: x + +Reading from a table, you must use an index. | byte one | @@ -346,6 +360,31 @@ Reading from a table, you must use an index, and vice-versa. | } = ok + | byte table[256] many + | + | routine main + | inputs many + | outputs many + | trashes a, x, n, z + | { + | ld x, 0 + | ld a, many + x + | } + = ok + +The index must be initialized. + + | byte table[256] many + | + | routine main + | inputs many + | outputs many + | trashes a, x, n, z + | { + | ld a, many + x + | } + ? UnmeaningfulReadError: x + Copying to and from a word table. | word one