Re: TIB: Faster Getkey??? (was GetKey)


[Prev][Next][Index][Thread]

Re: TIB: Faster Getkey??? (was GetKey)






>
>On Fri, 4 Dec 1998 22:35:29 -0500 "The Kellers" <sandia@rocler.qc.ca>
>writes:
>>
>>Here's the fastest thing I see to your proposition(look, no goto, no
>>subprograms :-) )
>>
>>Repeat 0
>>Repeat Ans
>>Getkey
>>End
>>If Ans = 105
>>then
>>Disp"Hi
>>Pause
>>End
>
>To save bytes, replace above IF loop with
>  :IF Ans=105
>  :Pause "HI
>
>>If Ans = 22
>>Stop
>>End
>>
>>Philipp Keller
>
>I also think this is the fastest Getky routine you can make.  It
clocks
>about 16 to 17 cycles per second, as apposed to about 9.5 c/sec for
a
>LBL/GOTO loop with the IF's enclosed in the loop.  Also, this
>REPEAT-based routine should perform at the same speed anywhere in the
>program.
>
>~Philip

I figure that's because with the REPEAT the calc jumps right to the
memory address of the beginning of the loop (wich was stored in the
stack) when it hits the END instead of searching the prog for a label,
that's why I keep telling people to try to avoid GOTOs entirely. Am I
right in assuming that in a large program, it takes even longer to
find the label? If so It could make even more of a difference in a
10Kb prog. Or maybe when the program is started, the memory address of
all the labels is stored in some kind of table or list and GOTO checks
this table for the mem address to jump to. Does anyone know?

But then, is a routine with subprograms as fast as  the prog I wrote
before? I'd think not because I believe it checks a Variable
Allocation Table or something for the Memory address of the program to
call. I think I remember reading something like that somewhere a while
back, but I'd appreciate it if someone could tell me if I'm right. I
would try it out myself, but I don't have a calculator for the
weekend(left it in school:-( ).

I just got totally obsessed with finding the fastest getkey routine
possible (maybe "least slow" would be a better term *L*)

Ok, remember, this is just speculation, I could be totally off.

Philipp Keller