[Coco] CoCo BASIC

Steve Ostrom smostrom7 at comcast.net
Tue Mar 23 20:47:10 EDT 2021


I’m trying to understand how BASIC handles arrays.

The routine to evaluate an array variable starts at location $B401.  The start address of the table for declared arrays is stored at $001D-$001E.  The end of this table +1 is stored at $001F-$0020.  The array flag is stored at $0005.

Each element in an array is stored as a 5-byte value.  In the array table, each array is preceded by a header block of 7 bytes for single dimensioned arrays or 9 bytes for a two dimensional array.  Those bytes are made up of 2 bytes for the array name, 2 bytes containing the length of the array plus the header, the fifth byte holds the number of dimensions, followed by 2 bytes for each dimension that contains the length of the dimension.

My guess is that the values for a single-dimensioned array are stored sequentially in the memory location reserved for arrays.  But how are the values for multidimensional arrays stored?  Sequentially by the first dimension, followed by values for the second dimension?

My goal is to set up arrays in BASIC, then access those arrays via assembly language.

Thanks again for the help.  Relearning this stuff has been fun, and good exercise for my 72 year old brain !!   😊

--- Steve ---



Sent from Mail for Windows 10




More information about the Coco mailing list