barrym95838 wrote:
BigEd wrote:
I'm all on board with idea of a minimal basic for a tiny system, and trying to do an integer-based mandelbrot on it. VTL02 is certainly worth a look, if you haven't looked yet. It's wonderful and terrifying.
I was wandering the web and came across
this:
A-Ha. Just the thing...
FWIW, a month or so back, I started with an IL Based TinyBasic on another CPU to port my Apricot programming language with, but ended up just porting/re-writing a TinyBasic - I'll do a longer post about it later on,,, Meanwhile I've been looking at my own Mandelbrot programs with a view to porting them using scaled integers, but this VTL program runs nicely when translated into my TB which supports 16 bit signed integers only.
Code:
>LIST
5 !160=0
10 F=50
20 Y=-12
30 X=-39
40 C=X*229/100
50 D=Y*416/100
60 A=C
70 B=D
80 I=0
90 Q=B/F : S=B-(Q*F)
100 T=((A*A)-(B*B))/F+C
110 B=2*((A*Q)+(A*S/F))+D
120 A=T
130 P=A/F : Q=B/F
140 IF ((P*P)+(Q*Q))>5 GOTO 180
150 I=I+1 : IF I<16 GOTO 90
160 PR " ";
170 GOTO 200
180 IF I>10 THEN I=I+7
190 VDU 48+I
200 IF X<39 THEN X=X+1 : GOTO 40
210 PR ""
220 IF Y<12 THEN Y=Y+1 : GOTO 30
230 PR "Time: ", !160/100, " secs."
>RUN
111111111111112222222222222333334568BD67543322222211111111111110000000000000000
11111111111111122222222233333344599C 77:44333222222111111111111100000000000000
111111111112222222222233334444556 965433332222211111111111110000000000000
111111111222222223233333456666778 976554444322222111111111100000000000000
11111112222222233333334457 :B: 788C5433222111111111000000000000000
11222222222333333333445667 533222111111111111000000000000
22222223334444444445556: 96543322211111111111111000000000
22222333345D6667 6665689 ::43322221111111111110000000000
22333333456: 8D E888: B44322221111111111110000000000
233333345578D E 44322222111111111100000000000
3344445789: 643322222111111111100000000000
5555668B C6543322222111111111100000000000
975443322221111111111100000000000
5555668B C6543322222111111111100000000000
3344445789: 643322222111111111100000000000
233333345578D E 44322222111111111100000000000
22333333456: 8D E888: B44322221111111111110000000000
22222333345D6667 6665689 ::43322221111111111110000000000
22222223334444444445556: 96543322211111111111111000000000
11222222222333333333445667 533222111111111111000000000000
11111112222222233333334457 :B: 788C5433222111111111000000000000000
111111111222222223233333456666778 976554444322222111111111100000000000000
111111111112222222222233334444556 965433332222211111111111110000000000000
11111111111111122222222233333344599C 77:44333222222111111111111100000000000000
111111111111112222222222222333334568BD67543322222211111111111110000000000000000
Time: 84 secs.
Without going into too many details here,
it fails the 2KB test, being 3.6KB right now (and needs external getchar/putchar/getline functions) but is quite "full featured" with DO/UNTL and FOR/NEXT. Also some BBC/Acorn-isms, like byte and word indirection (? and ! commands- the !160=0 above sets the centisecond timer to zero and !160 reads it). also VDU does the same as PRINT CHR$(x); It also supports strings to a degree, but memory management is left as an exercise to the user. Hex numbers are per the Acorn standard &12AB and to print, prefix with a ~.
I'll post more (plus sources) in a few days when I get it all together with some more demos, etc. but this isn't and never will be a 2K Basic (nor is it particularly fast - it's between 1.5 and 2 times slower than EhBasic - that time of 84 seconds is on a 16Mhz 6502) It might just fit into a small system with 4K of ROM and 1K of RAM though (512 bytes for your program though - tight!). I can shave off 100-200 bytes if needed for e.g. serial IO so making it fit into a 4K ROM ought to be fine.
Cheers,
-Gordon
Ps. Think I'll stick to keeping VTL read-only for now
![Wink ;-)](./images/smilies/icon_wink.gif)
_________________
--
Gordon Henderson.
See my
Ruby 6502 and 65816 SBC projects here:
https://projects.drogon.net/ruby/