[Coco] Optimizing BASIC

William Astle lost at l-w.ca
Fri Jan 2 21:00:34 EST 2015


On 15-01-02 06:35 PM, Andrew wrote:
> One method that I am probably mis-remembering - from a "improved speed"
> standpoint (and likely greater memory footprint) - was to have a GOTO at
> the top of your program that would jump to your "main loop", and any
> GOSUBs would be placed at the beginning of the program (after that first
> GOTO), with the most accessed subroutine coming first. At least - it was
> something like that...
>
> Anyhow - the concept only applied to interpreted BASIC - because the
> interpreter had to scan from the top of the listing to find the line
> number to GOSUB to - so the closer the most accessed routine was to the
> top of the code, the faster things went. Or at least, that's how I
> remember it. It's been years.

That's roughly correct. It is smart enough to search forward from the 
current line if the requested line number is later in the program. 
Otherwise it does start at the beginning and scan the program.


More information about the Coco mailing list