
Indeed BBC BASIC is particularly slow in one regard: the way that GOTO and GOSUB find their destination line by a linear search starting at the beginning of the program every time! I'm pretty sure there was no cacheing, or using a binary chop, or other optimisations. Whilst these are features that made BBC BASIC very powerful, and have helped it survive to today, they are not conducive to speed! These include having 40-bit floats, when most other BASICs had 32-bit floats, 32-bit integers when most others had 16-bit, arbitrarily long variable names etc. BBC BASIC is not inherently a fast language at all, indeed there are features of its design which might be expected to make it slower than its contemporaries. I'm sure this is the key reason why her BBC BASIC's are fast. Sophie Wilson clearly optimised the BBC BASIC for speed. The other thing I forgot to mention in connection with the BASIC intrepreter was that just having integer variables was a speed-up as these were quicker to calculate with than floating point.
#Fastest 6502 emulator full
On the BBC it ran full speed except when accessing the 1Mhz hardware That's an extreme case but a more general case, with RAM speed matched to the CPU, would be that the CPU would have wait states inserted during video generation so was probably running about half speed then, and full speed during flyback. So I think memory contention was the big thing, In the Sinclair ZX80, because the CPU was used as part of the video generation, no running of a user program happened during the period video was being displayed - only the flyback period was available for computation. Also, as I said, Z80A (4Mhz) CPUs were common. I think that's probably part of why the Z80 needs the clock to be twice as fast for the same throughput but I am not sure if it's the only factor. There are no doubt more tricks to be discovered but I think this is a sufficient clue that Sophie quite deliberately set out to write a fast BASIC interpreter.Īs far as I can tell from various z80 decapping videos it is a 4bit ALU and hence requires two cycles to do what the 6502 can do in one. The non-indexed instructions are faster than their indexed equivalents and it also saves time on the loop control (decrement, test, branch). In modern compiler-speak we would call this loop unrolling. In BBC BASIC it is written instead as four separate groups of instructions with no looping. An obvious way to add/subtract/copy these would be to write a loop that goes round 4 times and accesses the bytes via an index register.
#Fastest 6502 emulator series
The rest of the variable are stored in a series of linked lists, one for each possible starting letter.

The single letter integer variables (A% etc.) are stored in fixed locations for fast access.Sophie Wilson clearly optimised the BBC BASIC for speed.That was achieved by using RAM that was twice as fast as the CPU needed to accesses from the CPU and the video output could be interleaved. What is possibly unique about the BBC micro, though, is that there is no contention in the memory access between the CPU and the video circuitry. Although it is not a 1:1 comparison, it is generally accepted that a Z80 requires about twice as many clock cycles as a 6502 to do the same work so, all other things being equal, the BBC B with a 2Mhz 6502 would be about the same speed as machines with a 4Mhz Z80 which is where some of the other machines were at.

