Reply to post:

10 PRINT "ZX81 at 37" 20 GOTO 10

AndrueC Silver badge
Boffin

At least the membrane keyboard featured an early version of Intellisense, with commands and functions popping up while the user typed. A proficient user could rapidly fill the diminutive memory with only a few keystrokes.

Actually, no. Like all versions of BASIC that I'm aware of the keywords were tokenised once stored in memory. What the article author is describing is some slightly clever keyboard handling that knew the rules about keywords and automatically put the keyboard into an appropriate shift state such that keys generated token codes instead of letters.

With a lot of computers you typed 'PRINT "Hello"' and that was 13 characters. However a parser then stored that in memory as <PRINT token>"Hello" which meant it only occupied 8 bytes (note how the space after PRINT can be discarded by having the <PRINT token> expand to 'PRINT '.

What the ZX81 was doing (and the Speccy did the same) was to put the keyboard into a shift state whereby the 'p' key generated <PRINT token> (Character 0xF5 on the Speccy). This saved typing and simplified the parser but had no impact on the amount of memory consumed while entering program statements.

How interpreters optimise code storage is an interesting subject. My favourite 8-bit machine was the Amstrad CPC and its version of BASIC stored memory addresses alongside line numbers and variables to improve performance.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon