[Coco] [Color Computer] Question about BASIC coding guidelines
Diego Barizo
diegoba at adinet.com.uy
Fri Oct 31 08:34:07 EDT 2008
I did check that a while ago with some biggish program of mine, and
there was an improvement.
Also noticed speed changes when doing
FOR A=0 TO 1 STEP 0
code that might change X or Y
IF X=Y THEN A=1
NEXT A
Instead of
90 code that might change X or Y
100 IF X<>Y THEN 90
But the difference is only notorious if the routine is after many code
lines, because of the GOTO behavior explained before
Diego
Rogelio Perea wrote:
> 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.
>>
>>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
>
>
More information about the Coco
mailing list