[Coco] [Color Computer] Question about BASIC coding guidelines

shadow at shadowgard.com shadow at shadowgard.com
Thu Oct 30 10:04:07 EDT 2008


On 30 Oct 2008 at 3:10, James Diffendaffer wrote:

> As for searching through line numbers, Darren is right.  If the line
> number is lower than the current one the interpreter starts at the
> beginning.  If the line number is greater than the current one it
> starts searching at the next line.  (Just so you know, there are some
> BASICs out there that include the memory address of the lines being
> called so no search occurs.  Not on the CoCo though.)
> 
> There is one other important detail Darren left out.  Variables are
> searched from start to end of the variable storage area so you want to
> declare most used or time critical variables first.  Faster BASIC and
> Other Mysteries or some similar book detailed this.
> 
> Also, if you can keep a loop on a single line it's faster than spread
> over multiple lines.  Actually, if you can reduce the number of lines
> used by placing more on your lines the less searching has to take
> place and the faster it takes place since code is stored in sort of a
> linked list.  Less lines to search, the lest nodes in the list.  

Not sure if CoCo BASIC does this or not, but in other TRS-80 BASICs 
the line numbers for THEN, GOTO, GOSUB, etc are stored as literals.

Thus "GOTO 1000" takes two more bytes than "GOTO 10".

This makes a speed difference as well. 

When trying for speed, you want to number lines by *ones*. And statrt 
with:

0 GOTO ????

where ???? is the initialization routines. Line ne needs to be the 
most called subroutine,, etc.

--
Leonard Erickson (aka shadow)
shadow at shadowgard dot com





More information about the Coco mailing list