[Coco] CoCo BASIC Interpreter

James Jones jejones3141 at gmail.com
Sat Feb 20 13:20:45 EST 2021


Nope, that's not how it works.

Microsoft BASIC interpreters of that era did/do *very little* to the code.
They convert the line number to a two-byte integer and convert keywords and
names of built-in functions into one-byte or two-byte codes. Period.
*Nothing* is translated into machine language. Instead, there are routines
for each kind of statement (assignment, IF, GOTO, GOSUB, etc.) and for
parsing and evaluating expressions.

Every time the interpreter executes a statement, any expressions needing to
be evaluated are parsed (including all the fiddling with operator
precedence and parentheses), variables referenced each require a linear
search of the symbol table (is one in there twice? I'm pretty sure it gets
looiked up twice), constants converted from text into numeric format,
statement numbers converted from text into two byte integers and a linear
search done to find the matching statement.

That's why you see all the articles about how to mangle your BASIC code
into illegibility to minimize interpreter overhead

On Fri, Feb 19, 2021 at 9:36 PM Steve Ostrom <smostrom7 at comcast.net> wrote:

> OK, here’s a question about the CoCo BASIC interpreter for all of you guys
> and gals who know much more about interpreters than I do.
>
> Since CoCo BASIC is an interpreted language, I assume CoCo’s interpreter
> reads a line of BASIC code, then translates that to some version of machine
> code, then executes that ML code, then returns to the interpreter for the
> next line of BASIC.  Assuming this is mostly correct, where is that
> generated ML code stored temporarily?  What I would like to do is examine
> that ML code after the BASIC line is interpreted.  I’d need to be able to
> view the code plus the contents of most of the registers.
>


More information about the Coco mailing list