Closed dansanderson closed 4 months ago
More polish: We should type-check the STEP parameter and only allow integer steps in these cases. Right now you can provide a fractional STEP to an integer variable and it'll never terminate.
FOR currently disallows byte-type index variables. Clearing bit 5 of subflg
at the top of for:
disables the Type Mismatch Error, but more is needed for the variable to behave correctly within the body of the loop.
FOR has separate set-up behavior for integer index variables. I enhanced the test of intflg
to branch to forint:
for both integer and byte types. This improves (but does not completely fix) the index variable behavior in the loop, but attempts to add the STEP value and use its memory for comparison purposes treat it as a 16-bit integer, which corrupts memory and misbehaves.
The stack record uses the STEP exponent = 0 to indicate an integer type. There is currently no distinction between an integer and a byte in this record, and one is needed to prevent next:50$
from writing two bytes to byte variable memory. Integer values (variable, TO, STEP) appear to be treated as the low 16 bits of the FAC throughout this routine, so extending this routine to simply truncate at 8 bits for byte indexes should be a complete solution.
for b& = 0 to 3 : next b&
(byte variable) errors with Type Mismatch Error.for i% = 0 to 3 : next i%
(integer variable) succeeds.for i% = 0 to 32769 : next i%
errors immediately with Illegal Quantity Error.For completeness, support byte variables in FOR statements, and limit the value range with Illegal Quantity Error similar to integers.