[Coco] CoCo BASIC
Robert Gault
robert.gault at att.net
Tue Mar 23 22:01:25 EDT 2021
One thing you can try is with the MAME or MESS emulators. With Basic running in the emulator, assign an array of any type and switch to the MAME/MESS debugger and examine the memory.The above in conjunction with the UNRAVELLED documents should tell you what you want to know.
Sent from AT&T Yahoo Mail on Android
On Tue, Mar 23, 2021 at 8:51 PM, Steve Ostrom<smostrom7 at comcast.net> wrote: 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
--
Coco mailing list
Coco at maltedmedia.com
https://pairlist5.pair.net/mailman/listinfo/coco
More information about the Coco
mailing list