Closed szczys closed 6 years ago
I tested this with the old tokenizer and I get Unreachable line 2800 called from 302
Any idea what's causing that error?
Tried using gosub to lines that are not the 'rem' command but that doesn't seem to fix the problem.
10 D = 0
20 L = 1
30 C = 2
40 edr D,0
50 edr L,0
60 edr C,0
70 eout D,0
80 eout L,0
90 eout C,0
100 goto 300
300 Q=25
301 P=100
302 gosub 2810
310 gosub 2010
320 gosub 2210
330 gosub 2410
340 gosub 2610
350 goto 300
1000 rem Pulse clock
1010 eout C,1
1020 eout C,0
1030 return
1100 rem Pulse latch
1110 eout L,1
1120 eout L,0
1130 return
1200 rem Clock in "x" times
1210 for y=1 to x
1220 gosub 1010
1230 next y
1240 return
2000 rem Chopsticks FG
2010 eout D,0
2020 x=3
2030 gosub 1210
2040 eout D,1
2050 x=2
2060 gosub 1210
2070 eout D,0
2080 x=3
2090 gosub 1210
2100 gosub 1110
2110 tune 65,67,0,P
2111 wait P
2115 gosub 2810
2120 return
2200 rem Chopsticks EA
2210 eout D,0
2220 x=2
2230 gosub 1210
2240 eout D,1
2242 gosub 100
2244 eout D,0
2246 gosub 1210
2248 eout D,1
2250 gosub 1010
2252 eout D,0
2254 gosub 1210
2256 gosub 1110
2257 tune 64,69,0,P
2258 wait P
2259 gosub 2810
2260 return
2400 rem Chopsticks DB
2410 eout D,0
2412 gosub 1010
2414 eout D,1
2416 gosub 1010
2418 eout D,0
2420 x=4
2422 gosub 1210
2424 eout D,1
2426 gosub 1010
2428 eout D,0
2430 gosub 1010
2432 gosub 1110
2433 tune 62,71,0,P
2434 wait P
2435 gosub 2810
2436 return
2600 rem Chopsticks CC
2610 eout D,1
2612 gosub 1010
2614 eout D,0
2616 x=6
2618 gosub 1210
2620 eout D,1
2622 gosub 1010
2624 gosub 1110
2625 tune 60,71,0,P
2626 wait P
2627 gosub 2810
2628 return
2800 rem Clear and pause
2810 eout D,0
2820 x=8
2830 gosub 1210
2840 gosub 1110
2850 wait Q
2860 return
Please, rerun this code with 1.13 In 1.12, I added error code when GOSUB stack is overflown, it was silently ignored (and causing problems) before. Also, RETURN underflow was added in 1.13
I get gosub stack overflow at line 1220
after hearing the tones 4 times.
I didn't trace your code manually to count GOSUB levels, but it looks quite innocent. I just commited 1.14, with GOSUB stack depth increased from 10 to 30 levels. See if it helps. If not, you may have unbalanced GOSUB/RETURN.
I believe line 2242 was causing the problem... It's a gosub to 100 instead of 1000. I'll do more testing and then close.
Sorry if I wasted time on this. I do think the overflow error is a good one to have enabled.
No time wasted, this is very valuable practical feedback. The overflow indication is definitely needed and now we have it. Also, I need to add overflow indication for nested FOR loops.
Everything is working as expected with GOSUB. the error was in my code.
I'm testing out a program and believe I've encountered some problem with calling GOSUB from withing a GOSUB call. Is this not allowed? I'm getting bizarre behavior. You can try this out -- I'm using external circuit but you should still hear the notes int he speaker and they should be changing instead of repeating.