Another program showing off interesting features of the interpreter. Note that the code is not presented in execution order, but when pasted in it will effectively be sorted by line number. This takes approximately 1.2 million cycles to complete, and then executing the program takes several million more.
Code:
5000 PRINT D,"|",(18432*100)/(D*16);
5010 F=(18432*10000/(D*16))-(18432*100/(D*16))*100
5011 GOSUB 4000
5020 PRINT " |",(24576*100)/(D*16);
5030 F=(24576*10000/(D*16))-(24576*100/(D*16))*100
5031 GOSUB 4000
5040 PRINT " |",(18432*200)/(D*16);
5050 F=(18432*20000/(D*16))-(18432*200/(D*16))*100
5051 GOSUB 4000
5060 PRINT
5070 RETURN
4000 IF F PRINT ".";F/10;F-(F/10*10);
4010 RETURN
10 D=1
20 D=2
30 D=3
40 D=4
50 D=6
60 D=8
70 D=12
80 D=16
90 D=24
100 D=32
110 D=48
120 D=64
130 D=96
140 D=128
150 D=192
160 D=256
170 D=384
180 D=512
190 D=576
200 D=768
210 D=856
220 D=1047
230 D=1142
240 D=1396
250 D=1536
260 D=1713
270 D=2048
280 D=2095
290 D=2304
300 D=2534
310 D=3072
320 D=3379
15 GOSUB 5000
25 GOSUB 5000
35 GOSUB 5000
45 GOSUB 5000
55 GOSUB 5000
65 GOSUB 5000
75 GOSUB 5000
85 GOSUB 5000
95 GOSUB 5000
105 GOSUB 5000
115 GOSUB 5000
125 GOSUB 5000
135 GOSUB 5000
145 GOSUB 5000
155 GOSUB 5000
165 GOSUB 5000
175 GOSUB 5000
185 GOSUB 5000
195 GOSUB 5000
205 GOSUB 5000
215 GOSUB 5000
225 GOSUB 5000
235 GOSUB 5000
245 GOSUB 5000
255 GOSUB 5000
265 GOSUB 5000
275 GOSUB 5000
285 GOSUB 5000
295 GOSUB 5000
305 GOSUB 5000
315 GOSUB 5000
325 GOSUB 5000
330 GOTO 65535
The main features thus demonstrated/exercised are the memory management for program code, the use of 32-bit internal arithmetic to support fixed-point, and nested subroutine calls. In a more complete and conventional BASIC interpreter, this would be a natural place to use DATA and READ, which I don't have - nor is there an END or STOP, but a contrived GOTO past the end of the program also works.
The output is a table of the baud rates for my "improved ACIA" proposal:
Attachment:
BaudRates.png [ 24.26 KiB | Viewed 35288 times ]