Jump to content
IGNORED

Atari BASIC Variable Value entry number


Recommended Posts

Is there any situation where the entry number in the Variable Value (VVTP) table structures would not be sequential from entry to entry? Either values out of order or gaps >+1 between adjacent entries?

 

Been poking around and can't come up with a reasonable circumstance that causes the entries to be disordered.

 

BASIC uses the tokenized variable number to index into the VVTP to get the Variable Value structure. So...it seems that the entries are always created sequentially and gaps should not be possible. Then the entry number in the variable value structure is really just redundant/does not serve a purpose.

Link to comment
Share on other sites

The VVT entries are always sequential and ordered.

 

The reason for the index in the VVT is that the entire 8 byte variable entry, including the token value, is copied onto the runtime stack during expression evaluation. This allows the interpreter to later trace the entry back to the variable when needed, since the code that stacks the variables doesn't know whether it'll be used as an lvalue or an rvalue. For instance, when evaluating A=B, the interpreter pushes both A and B onto the stack before calling the = operator, and the = operator uses the token byte from the A entry to write the result to A.

 

As it turns out, both the type and the token bytes are unnecessary on the runtime stack since the type can be determined by the most recent operator and the lvalue is always the first element pushed onto the stack. In Altirra BASIC, I omitted these two and only push 6 bytes onto the runtime stack instead of 8.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...