I finally implemented my solution to improve long range goto and gosub.
The variable {=} is now asigned to gosub and return. {==...} is a gosub and pushes the physical address of the next program line on a 16 deep word stack. {#==} is a return. The {=} on the right hand side of the equation does not actually pop the return address of the stack, but it inserts a special line number (65280+'=') into the equation. The actual pop is only done, when the line number is to be stored to {#}. The return stack is located in the hardware stack area from $140 to $15F.
A label array for 31 line addresses is located at $100-$13D. Lower case characters and symbols $60-$7E address the array. Same as with {=} only a special line number of 65280 + ASCII value is inserted. You could even create a switch case with it as {#=a+2} would actually generate the same line number as {#=c}. The lable array is cleared on reset and when a program line is added, replaced or deleted. The label array is populated when a direct statement is executed. A character >$60 in column 1 signals the line whose address is to be loaded to the corresponding location in the label array.
So a revised version of my prime number program looks like this:
Code:
&=1024
10 /=0;Q=d;V=5;U=25;X=1000
20 N=2;==b
30 N=N+1;==b
40 N=N+2;==b
a100 N=N+2;==b
120 N=N+4;==b
150 #=a
b200 #=N<U[Q;Q=c;V=V+2;U=V*V
c300 D=5
310 A=N/D;#=%]=;D=D+2;#=D>V[d;A=N/D;#=%]=;D=D+4;#=D<V[310
d400 ?=N;?=""
420 X=X-1;#=X[=
435 ?="Execution time: ";
445 ?=//100;$=46;#=%>10[465;?=0
465 ?=%;?=" seconds"
#=1
There is only a small gain in performance for a small program. The label array should be used for far away (many lines to be skipped) and frequently used lines to be most effective. It is actually faster to use the line number instead of the label array, if you want to go to the beginning of the same line again.
I have now almost filled 2k. The only thing left to do for me is a bit of cleanup and better documentation.