Re: BASIC for the CBM-II/8088

From: Rhialto <rhialto_at_falu.nl>
Date: Thu, 5 Jul 2018 20:27:12 +0200
Message-ID: <20180705182712.GP20645@falu.nl>
On Thu 05 Jul 2018 at 16:34:55 +0200, Mia Magnusson wrote:

> > > Storing the variables. Again I don't know exactly how BASIC saves it
> > > variables.
> 
> There are some stuff online about this. In short it has a table
> (dynamically resized as needed) that contains a list of all variable
> names, types and for floats and integers the actual values. For arrays
> it instead points to where in the array area the variable is, and for
> strings it points to where the string is stored.

Each (non-array) variable takes up a slot of 7 bytes. 2 of those are the
name. The 2 high bits of the name are set in various combinations to
indicate the type (AB, AB$, AB%).

See for instance at
https://archive.org/stream/transactor-anthology/anthology#page/n7/mode/2up

Variables are only ever added, never removed, so there is no garbage
collection for them, only for the values of strings.

> If you have a linje like 10 A$="HELLO" then the pointer for A$ would
> actually point into the stored program. But if you have a line like 20
> B$="HEL"+"LO" then space will be allocated for the resultant string and
> the pointer for B$ will point to that space. If B$ is shrunk the
> existing length will be retained, while if B$ grows then a new space
> will be allocated (maybe it deletes the old if it were the last stored
> in the string space). This is the reason for the need of garbage
> collection.
> 
> On VIC-20/C64 the pointers for these areas are somewhere around 43
> (decimal) in zero page.

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- Wayland: Those who don't understand X
\X/ rhialto/at/falu.nl      -- are condemned to reinvent it. Poorly.


Received on 2018-07-05 21:00:07

Archive generated by hypermail 2.2.0.