Difference between revisions of "DIM Basic432"

From BeebWiki
Jump to: navigation, search
m
m
Line 3: Line 3:
 
Correction to the [[DIM]] statement for BASIC 4r32.
 
Correction to the [[DIM]] statement for BASIC 4r32.
  
[[6520_BBC_BASIC#BASIC_4.32.2C_HIBASIC_4.32|HIBASIC 4.32]] added the following check in the Multiply Upper Dimension by Lower Dimension routine:
+
[[6502_BBC_BASIC#BASIC_4.32.2C_HIBASIC_4.32|HIBASIC 4.32]] added the following check in the Multiply Upper Dimension by Lower Dimension routine:
 
<pre>      [&95E4] BCS 11 --> &95F1 Bad Dim error</pre>
 
<pre>      [&95E4] BCS 11 --> &95F1 Bad Dim error</pre>
  

Revision as of 22:37, 8 March 2015


Correction to the DIM statement for BASIC 4r32.

HIBASIC 4.32 added the following check in the Multiply Upper Dimension by Lower Dimension routine:

      [&95E4] BCS 11 --> &95F1 Bad Dim error

this occurs after we have multiplied &2A-&2B by 2, and avoids memory corruption if the number of elements to dimension (&2A-&2B) is too large. This check now correctly disallows arrays to be DIMmensioned, where the number of elements would exceed 65535 (&FFFF). In BASIC IV, DIM K(1582,127) was allowed (total of 200914 elements!) which caused the following weird bug:

>L. 
10 DIM K(1582,127) 
20 FOR I% =1 TO 1582 
30 FOR J%=1 TO 127 
40 K(I%,J%)=56.77777 
50 NEXT J% 
60 NEXT I% 
>RUN 

Array at line 40 
>L. 
0 DIM K(1582,127) 
0 FOR I% =1 TO 1582 
0 FOR J%=1 TO 127 
0 K(I%,J%)=56.77777
0 NEXT J% 
0 NEXT I%
>

Memory was corrupted, causing BASIC to become confused. In BASIC4 r32, DIM K(1582,127) now produces 'Bad DIM' error.