[Coco] Question about BASIC coding guidelines

theother_bob theother_bob at yahoo.com
Fri Oct 31 20:11:53 EDT 2008


I don't know about that for sure, but I can say from first hand benchmarking that it speeds Basic up to use Hex numbers instead of decimal. To prove it, try the following benchmarks:
 
10 TIMER=0:FOR X=1 TO 1000:N=&HC0C0*&H2:NEXT:T=TIMER;?T
 
10 TIMER=0:FOR X=1 TO 1000:N=49344*2:NEXT:T=TIMER:?T
 
I'm not actually running these now, but I'm confident you will see a faster time on the first example in RS Basic.

For Benchmarking especially, it is best to eliminate as much OS overhead as possible. Keep lines to the least (and lowest) number possible, put subroutines at the beginning of the program, declare frequently used variables first... all good practices I have experienced noticeable improvements from. There are also some POKEs that can make really major speed and security improvements in Basic.

Cheers,
Bob


----- Original Message ----
From: Bill Barnes <da3m0n_slay3r at yahoo.com>
To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
Sent: Thursday, October 30, 2008 2:03:20 PM
Subject: Re: [Coco] Question about BASIC coding guidelines

Based on this, it would be faster to make all numeric constants within a program to be assigned to a variable within basic. Only drawback is if you accidently modify the value of the variable, as the CoCo BASIC doesn't allow for c constant variable. 

-Later!
-WB-    -- BABIC Computer Consulting.

--- On Thu, 10/30/08, Darren A <mechacoco at gmail.com> wrote:
From: Darren A <mechacoco at gmail.com>
Subject: Re: [Coco] [Color Computer] Question about BASIC coding guidelines
To: "CoCoList for Color Computer Enthusiasts" <coco at maltedmedia.com>
Date: Thursday, October 30, 2008, 1:54 PM

On 10/30/08, James Diffendaffer  wrote:
>
> I know some BASICs tokenize the number (store it as a 16bit integer)
> which makes the code smaller and faster (ok... if you don't get out of
> single digit line numbers it might not be smaller).  I don't remember
> what the CoCo does.
>

The CoCo does not tokenize the line numbers following GOTO, GOSUB and
THEN. It performs an ASCII to Integer conversion every time such a
statement is executed.  Likewise, literal numbers in expressions must
go through an even lengthier ASCII to FP conversion.

Darren

--
Coco mailing list
Coco at maltedmedia.com
http://five.pairlist.net/mailman/listinfo/coco



      

--
Coco mailing list
Coco at maltedmedia.com
http://five.pairlist.net/mailman/listinfo/coco



      



More information about the Coco mailing list