Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type of interpreter were most 8-bit BASIC implementations?

I’m a big fan of early/mid 1980s personal computers like the Amstrad CPC, Commodore 64 and the Sinclair Spectrum. One thing these computers all had was a version of BASIC.

As a language hacker myself I’m curious: were these interpreters implemented as tree-walker interpreters (simply traversing the parse tree) or bytecode interpreters? I can’t find a lot of information on how they were implemented. It’s fascinating to me how they were built given the limitations of the hardware at the time.

like image 449
Garry Pettet Avatar asked Oct 26 '25 10:10

Garry Pettet


1 Answers

They were mostly token based. This means, that the integrated code editor transformed the human readable commands in the source into a bytecode. Upon execution those bytecodes were read and a dispatcher then executed the appropriate command (stored as machine code in the kernal) with the given parameters. The ZX Spectrum even had a keyboard to enter Basic Tokens:

http://www.worldofspectrum.org/ZX81BasicProgramming/

For some others see here:

https://www.primidi.com/atari_basic/description/the_tokenizer

http://fileformats.archiveteam.org/wiki/Commodore_BASIC_tokenized_file

http://cpctech.cpc-live.com/docs/bastech.html

Hope this anwers your question.

like image 188
avans Avatar answered Oct 28 '25 02:10

avans