6 ms·
Well, there's an annotated disassembly here: http://acorn.huininga.nl/pub/docs/sourcecode/Acorn/BASIC%202/BASIC2.asm http://acorn.huininga.nl/pub/docs/sourceco
by david-given 10y ago
Well, there's an annotated disassembly here:
http://acorn.huininga.nl/pub/docs/sourcecode/Acorn/BASIC%202/BASIC2.asm http://acorn.huininga.nl/pub/docs/sourcecode/Acorn/BASIC%202...
AFAIK there wasn't anything particular magical about it --- it was just written well, with great care. Programs were stored in tokenised form, where each keyword was reduced to a byte, and line numbers in things like GOTO statements were stored preparsed, but execution happened directly from the tokenised form. Named procedures were faster than GOTOs because the interpreter would cache the address of the line where they were defined, while GOTOs would have to search for the line; variables were stored in a hash table; there were two stacks, one for GOSUBs and one for PROCs (the GOSUB stack was much smaller!); there was a superb 5-byte floating point library...
It's also worth mentioning that Acorn's MOS was in a different ROM, so it didn't have to share space with Basic. The two communicated via a system call interface. I've seen people run BBC Basic on entirely different 6502 machines by reimplementing the system call interface.
I would not recommend writing this style of Basic if you want a simple language these days. Basics are a nightmare of ad-hoc parsing with too many edge cases. Better to write a modern byte-compiled language with a byte interpreter --- you'll end up with something much cleaner and easier to understand. We're not all Sophie Wilson.
- bootload 10y ago"I would not recommend writing this style of Basic if you want a simple language these days. Basics are a nightmare of ad-hoc parsing with too many edge cases. Better to write a modern byte-compiled language with a byte interpreter --- you'll end up with something much cleaner and easier to understand." thankyou for these suggestions. "We're not all Sophie Wilson." agree, very talented individual.