[Coco] Optimizing BASIC (was: Expanding 4K Coco Mem)

Allen Huffman alsplace at pobox.com
Fri Jan 2 22:09:25 EST 2015


> On Jan 2, 2015, at 7:35 PM, Andrew <keeper63 at cox.net> 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…

Yes yes, I believe this is true. However, I would need to consult the Unravelled disassembly to know if BASIC starts from where you are and scans FORWARD (if the line number is higher) or always goes to the start. If it moves FORWARD, you might be better off having it after a cluster of code that uses it… It would just depend on how many lines it has to skip in either direction. I bet a smart optimizer could figure that out. Imagine the weirdness when it scattered GOSUB routines all over the places based on their usage patterns ;-)

> 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.


Good memory!
--
Allen Huffman - PO Box 22031 - Clive IA 50325 - 515-999-0227 (vmail/TXT only)
Sub-Etha Software - http://www.subethasoftware.com - Established 1990!
Sent from my MacBook.

P.S. Since 4/15/14, I have earned OVER $600  in Amazon gift cards via Swagbucks! Use my link and I get credit:
http://swagbucks.com/refer/allenhuffman







More information about the Coco mailing list