How To

Max array size

1

SP4CEBAR 2024-01-30 14:27

I just found that 2^15-1 is the maximum size of an array. And contrary to what I thought for years, you can have as many arrays of this size as you like.


SP4CEBAR 2024-01-30 14:35

These arrays have the same number of variables as there are bytes in ROM


SP4CEBAR 2024-01-30 14:36

Which is twice as much as the working RAM


SP4CEBAR 2024-01-30 14:43

It takes 15 frames to FOR loop through a max-sized array and assign a value to each index


SP4CEBAR 2024-01-30 14:50

You can shave two frames off of that if, instead of using UBOUND(A,1) you use UBOUND(A) or a variable


SP4CEBAR 2024-01-30 14:54

A function call in this loop adds four frames, and then two frames for each parameter passed to the function


SP4CEBAR 2024-01-30 15:04

The FOR itself loop accounts for 6 frames, a value assignment to a variable for 6 frames too, and a value assignment to an array for 7 frames


Timo 2024-01-31 11:00

As the memory for variables (and the BASIC interpreter in general) is not inside the "virtual machine", I just set arbitrary limits to avoid explosions ;)


SP4CEBAR 2024-01-31 15:16

That makes perfect sense


Log in to reply.