6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 3:27 am

All times are UTC




Post new topic Reply to topic  [ 136 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9, 10  Next
Author Message
PostPosted: Sat Sep 23, 2023 3:57 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
barrym95838 wrote:
I have never used Acorn Atom BASIC, but it looks like it might have some valuable ideas on how you could proceed. Atom BASIC reportedly resided in a 4KB ROM, but it's not clear to me how much of that was dedicated to the editor/interpreter.


Basic was 4K but the Operating system was another 4K - so Basic was relieved of the task of dealing with keyboard, video, etc. so more of those precious bytes could be thrown at its Basic...

This was further expanded to the Acorn/BBC Micro which had a 16K Basic and 14K Operating system. (16K minus IO).

I'm not that familiar with the Atom, but an example from the Beeb might be reading in a line of text with editing - you call an OS routine called OSWORD with a parameter block that has the code - code 0 is read line.

Here is an example from one of my things:

Code:
.proc   getline
        ldx     #<getLineData
        ldy     #>getLineData
        lda     #0
        jmp     osWord

getLineData:
        .word   keyboardIn              ; Address of input buffer
        .byte   76                      ; Max length
        .byte   32                      ; Smallest value to accept
        .byte   126                     ; largest...
.endproc


I applied this to my porting of EhBASIC, MS-Basic and to my own projects. Makes life so much easier and you get a consistent interface not matter what you run under the OS.

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 23, 2023 6:43 pm 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
Technically, the I/O space on the Beeb is 3 pages (SHEILA for internal peripherals, FRED and JIM for the 1MHz Expansion Bus), so the OS ROM is effectively 15.25 KB. The top page ($FFxx) above SHEILA mostly contains the API entry points, so for example JSR OSWRCH leads to $FFEE, at which there is a simple indirect JMP through a hook vector. Certainly you can do a lot of fancy stuff with 32KB of ROM that won't be feasible in 2KB.

Line input is a subroutine in my code, and supports as a basic editing feature using BS/DEL to erase the last character - so not exactly libreadline. It's hardwired to use Page 1 as the buffer. At the moment the subroutine is only called from one place, but it'll also get used by the INPUT statement. So far I haven't attempted to introduce "well known entry points" for the I/O routines, but they are small enough that duplicating them would not be a great burden.

I think it was Atom BASIC that was reputed to be "fast but very quirky". Similar programming techniques were combined with a more conventionally useful feature set to produce BBC BASIC.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 03, 2023 7:39 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Chromatix wrote:
Several operators will be implemented as combinations of other operators to reduce code size...
PEEK will likely be a unary operator, since it fits neatly into the above scheme. I may use the BBC BASIC indirection operators, ? and !, instead of the PEEK keyword, since they are easier to write recognition code for...

Great to see your progress Chromatix, and thanks for the notes on the internals.

Chromatix wrote:
I'm not promising FOR-NEXT just yet, but as you can see, REPEAT-UNTIL already works. There may well be room to add FOR-NEXT, but it's actually a relatively complex construct to implement...

Interesting!


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 04, 2023 6:42 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
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:
Code:
5 ) MANDELBROT.VTL
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 ;=((P*P)+(Q*Q))>5 #=180
150 I=I+1 ;=I<16 #=90
160 ?=" ";
170 #=200
180 ;=I>10 I=I+7
190 $=48+I
200 ;=X<39 X=X+1 #=40
210 ?=""
220 ;=Y<12 Y=Y+1 #=30


Looks like the 4004 rendered it in a touch under 3 hours:
Attachment:
mandel.jpg
mandel.jpg [ 1.83 MiB | Viewed 19609 times ]


My joy was premature, because it's immediately clear that this is a non-standard impementation, with multiple statements per line (easy fix) and signed 16-bit integers (a bit more difficult). If I have some time I'll play around with it next weekend. I'm optimistic that I'll demolish the 4004's time, even with a soft-kludge for negative integers. A Woz BASIC version should definitely come first, but I'll have to go 80-columns with a PR#3 and hope that the firmware plays nicely. Curiously, VTL-2 has a built-in version of PRINT CHR$(), but Woz BASIC doesn't.

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 04, 2023 9:31 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
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 ;-)

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 05, 2023 12:40 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Nicely done! Your output doesn't quite match the reference image, because in VTL-2 < means less than and > is its logical complement, which is greater than or equal to :D

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 05, 2023 6:05 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
barrym95838 wrote:
Nicely done! Your output doesn't quite match the reference image, because in VTL-2 < means less than and > is its logical complement, which is greater than or equal to :D


Ah, I did wonder why it was slightly different but it was getting late last night... Fixed it to get...

Code:
111111111111111111222222222333334568BC67443322222211111111111000000000000000000
11111111111111111122222222233344598C  77943333222221111111110000000000000000000
111111111111112222222233324444556       955433332211111111100000000000000000000
111111111211112222222333455665778       976554444222211111100000000000000000000
11111112222222233333334457 AB9              787B5432111111111100000000000000000
11112222222222333333444667                       532222111111111000000000000000
11111222333444444444555A                       96443322211111110000000000000000
12222223345D6657 6555679                        AA43322211111110000000000000000
222233334569  8C  E8789                          B43322111111110000000000000000
223333345578D        E                            43322211111111111100000000000
3344444789A                                      543322111111111111100000000000
5555658A                                       C6433222222111111111100000000000
                                              975443322221111111111100000000000
5555658A                                       C6433222222111111111100000000000
3344444789A                                      543322111111111111100000000000
223333345578D        E                            43322211111111111100000000000
222233334569  8C  E8789                          B43322111111110000000000000000
12222223345D6657 6555679                        AA43322211111110000000000000000
11111222333444444444555A                       96443322211111110000000000000000
11112222222222333333444667                       532222111111111000000000000000
11111112222222233333334457 AB9              787B5432111111111100000000000000000
111111111211112222222333455665778       976554444222211111100000000000000000000
111111111111112222222233324444556       955433332211111111100000000000000000000
11111111111111111122222222233344598C  77943333222221111111110000000000000000000
111111111111111111222222222333334568BC67443322222211111111111000000000000000000


Thanks,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 07, 2023 3:16 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
Just FYI - I've published my 3.7K Tiny Basic and put a post about it here: viewtopic.php?f=2&t=7777

Cheers,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 10, 2023 12:40 am 
Offline
User avatar

Joined: Fri Sep 08, 2017 9:41 pm
Posts: 43
Location: UK Expat living in Washington State, US
Excellent work Drogon! - so now we have access to multiple BASIC versions for the 6502:What a time to be alive! :D


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 10, 2023 3:37 am 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
I'm glad you have such faith in me, but even I don't think I can squeeze a BASIC interpreter into two bytes!


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 10, 2023 5:27 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 988
Location: Potsdam, DE
Well, in the eighties (IIRC) some genius designed a file compression system which he claimed could compress *any* file, including its own compressed files. He wasn't happy when someone pointed out that if you kept compressing on that basis, sooner or later you'd end up with a one-byte file...

Neil


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 10, 2023 6:42 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
VinCBR900 wrote:
Excellent work Drogon! - so now we have access to multiple BASIC versions for the 6502:What a time to be alive! :D


And the fastest, most capable BASIC of them all, BBC Basic.

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 10, 2023 6:53 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
It's quite the palette of possibilities! I'm willing to offer an extra 2046 bytes to Chromatix though, if that's enough. Thanks for the list, VinCBR900!


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 12, 2023 2:45 am 
Offline

Joined: Sun Feb 22, 2004 9:01 pm
Posts: 111
Chromatix wrote:
I'm glad you have such faith in me, but even I don't think I can squeeze a BASIC interpreter into two bytes!

Challenge accepted!

BRA &8000

Conditions:
Must run on a BBC Micro with 65C02 CPU, and must be placed in memory between &7F80 and &7FFE, must be entered with A=1, and BBC BASIC must be paged in.
:mrgreen:

_________________
--
JGH - http://mdfs.net


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 13, 2023 3:19 am 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
Har de har - that's just calling an existing BASIC interpreter, not implementing a new one.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 136 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9, 10  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 37 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: