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

Rogelio Perea os9dude at gmail.com
Thu Oct 30 04:57:34 EDT 2008


I don't know if this would translate to the CoCo's Basic implementation: In
order to speed up program execution time it was suggested to put all
subroutines at the beginning of a program, that meant starting off with a 0
GOTO XXX line sending control of the program to a bottom part where all
variables were declared and then branch back to continue normal execution -
all called subroutines within the running program would GOSUB to the initial
lines of the code.

This came from a TRS-80 Graphics book while discussing the implementation of
an arcade game in Basic.

Should probably toy with two versions of the same program this weekend and
benchmark (if possible) any speed improvements/fallbacks between the two:
one written in straightforward fashion and the other with the jump to
declare + subroutines at the beggining.



-=[ R ]=-




On Wed, Oct 29, 2008 at 11:10 PM, James Diffendaffer <
jdiffendaffer at yahoo.com> 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.
>



More information about the Coco mailing list